diff --git a/.coveragerc b/.coveragerc
index c625e5b..f77eadc 100644
--- a/.coveragerc
+++ b/.coveragerc
@@ -2,7 +2,6 @@
branch = True
[report]
-fail_under = 100
show_missing = True
omit =
google/cloud/redis/__init__.py
diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml
index da616c9..e2b39f9 100644
--- a/.github/.OwlBot.lock.yaml
+++ b/.github/.OwlBot.lock.yaml
@@ -1,3 +1,3 @@
docker:
image: gcr.io/repo-automation-bots/owlbot-python:latest
- digest: sha256:c66ba3c8d7bc8566f47df841f98cd0097b28fff0b1864c86f5817f4c8c3e8600
+ digest: sha256:99d90d097e4a4710cc8658ee0b5b963f4426d0e424819787c3ac1405c9a26719
diff --git a/.kokoro/samples/python3.9/common.cfg b/.kokoro/samples/python3.9/common.cfg
new file mode 100644
index 0000000..418443f
--- /dev/null
+++ b/.kokoro/samples/python3.9/common.cfg
@@ -0,0 +1,40 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+# Build logs will be here
+action {
+ define_artifacts {
+ regex: "**/*sponge_log.xml"
+ }
+}
+
+# Specify which tests to run
+env_vars: {
+ key: "RUN_TESTS_SESSION"
+ value: "py-3.9"
+}
+
+# Declare build specific Cloud project.
+env_vars: {
+ key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
+ value: "python-docs-samples-tests-py39"
+}
+
+env_vars: {
+ key: "TRAMPOLINE_BUILD_FILE"
+ value: "github/python-redis/.kokoro/test-samples.sh"
+}
+
+# Configure the docker image for kokoro-trampoline.
+env_vars: {
+ key: "TRAMPOLINE_IMAGE"
+ value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
+}
+
+# Download secrets for samples
+gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
+
+# Download trampoline resources.
+gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
+
+# Use the trampoline script to run in docker.
+build_file: "python-redis/.kokoro/trampoline.sh"
\ No newline at end of file
diff --git a/.kokoro/samples/python3.9/continuous.cfg b/.kokoro/samples/python3.9/continuous.cfg
new file mode 100644
index 0000000..a1c8d97
--- /dev/null
+++ b/.kokoro/samples/python3.9/continuous.cfg
@@ -0,0 +1,6 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+ key: "INSTALL_LIBRARY_FROM_SOURCE"
+ value: "True"
+}
\ No newline at end of file
diff --git a/.kokoro/samples/python3.9/periodic-head.cfg b/.kokoro/samples/python3.9/periodic-head.cfg
new file mode 100644
index 0000000..f9cfcd3
--- /dev/null
+++ b/.kokoro/samples/python3.9/periodic-head.cfg
@@ -0,0 +1,11 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+ key: "INSTALL_LIBRARY_FROM_SOURCE"
+ value: "True"
+}
+
+env_vars: {
+ key: "TRAMPOLINE_BUILD_FILE"
+ value: "github/python-pubsub/.kokoro/test-samples-against-head.sh"
+}
diff --git a/.kokoro/samples/python3.9/periodic.cfg b/.kokoro/samples/python3.9/periodic.cfg
new file mode 100644
index 0000000..50fec96
--- /dev/null
+++ b/.kokoro/samples/python3.9/periodic.cfg
@@ -0,0 +1,6 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+ key: "INSTALL_LIBRARY_FROM_SOURCE"
+ value: "False"
+}
\ No newline at end of file
diff --git a/.kokoro/samples/python3.9/presubmit.cfg b/.kokoro/samples/python3.9/presubmit.cfg
new file mode 100644
index 0000000..a1c8d97
--- /dev/null
+++ b/.kokoro/samples/python3.9/presubmit.cfg
@@ -0,0 +1,6 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+ key: "INSTALL_LIBRARY_FROM_SOURCE"
+ value: "True"
+}
\ No newline at end of file
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 4f00c7c..62eb5a7 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -16,7 +16,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v3.4.0
+ rev: v4.0.1
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a6f8a71..5e4531f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,23 @@
[1]: https://pypi.org/project/google-cloud-redis/#history
+## [2.2.0](https://www.github.com/googleapis/python-redis/compare/v2.1.1...v2.2.0) (2021-07-01)
+
+
+### Features
+
+* add always_use_jwt_access ([#88](https://www.github.com/googleapis/python-redis/issues/88)) ([223cac0](https://www.github.com/googleapis/python-redis/commit/223cac02e172a6fe2bdee207d3b9e1973015e58c))
+
+
+### Bug Fixes
+
+* disable always_use_jwt_access ([#92](https://www.github.com/googleapis/python-redis/issues/92)) ([1f0b236](https://www.github.com/googleapis/python-redis/commit/1f0b23654a007ee62fa24fb85ba85362e9fdc9d8))
+
+
+### Documentation
+
+* omit mention of Python 2.7 in 'CONTRIBUTING.rst' ([#1127](https://www.github.com/googleapis/python-redis/issues/1127)) ([#83](https://www.github.com/googleapis/python-redis/issues/83)) ([3a64290](https://www.github.com/googleapis/python-redis/commit/3a642900cb9b0ab6fc2dd143c1ccac6a34b30209))
+
### [2.1.1](https://www.github.com/googleapis/python-redis/compare/v2.1.0...v2.1.1) (2021-05-28)
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index 8386999..0824230 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -68,15 +68,12 @@ Using ``nox``
We use `nox `__ to instrument our tests.
- To test your changes, run unit tests with ``nox``::
+ $ nox -s unit
- $ nox -s unit-2.7
- $ nox -s unit-3.8
- $ ...
+- To run a single unit test::
-- Args to pytest can be passed through the nox command separated by a `--`. For
- example, to run a single test::
+ $ nox -s unit-3.9 -- -k
- $ nox -s unit-3.8 -- -k
.. note::
@@ -143,8 +140,7 @@ Running System Tests
- To run system tests, you can execute::
# Run all system tests
- $ nox -s system-3.8
- $ nox -s system-2.7
+ $ nox -s system
# Run a single system test
$ nox -s system-3.8 -- -k
@@ -152,9 +148,8 @@ Running System Tests
.. note::
- System tests are only configured to run under Python 2.7 and
- Python 3.8. For expediency, we do not run them in older versions
- of Python 3.
+ System tests are only configured to run under Python 3.8.
+ For expediency, we do not run them in older versions of Python 3.
This alone will not run the tests. You'll need to change some local
auth settings and change some configuration in your project to
@@ -218,8 +213,8 @@ Supported versions can be found in our ``noxfile.py`` `config`_.
.. _config: https://github.com/googleapis/python-redis/blob/master/noxfile.py
-We also explicitly decided to support Python 3 beginning with version
-3.6. Reasons for this include:
+We also explicitly decided to support Python 3 beginning with version 3.6.
+Reasons for this include:
- Encouraging use of newest versions of Python 3
- Taking the lead of `prominent`_ open-source `projects`_
diff --git a/docs/conf.py b/docs/conf.py
index 670044d..de6bb49 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -80,9 +80,9 @@
master_doc = "index"
# General information about the project.
-project = u"google-cloud-redis"
-copyright = u"2019, Google"
-author = u"Google APIs"
+project = "google-cloud-redis"
+copyright = "2019, Google"
+author = "Google APIs"
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@@ -281,7 +281,7 @@
(
master_doc,
"google-cloud-redis.tex",
- u"google-cloud-redis Documentation",
+ "google-cloud-redis Documentation",
author,
"manual",
)
@@ -313,13 +313,7 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
- (
- master_doc,
- "google-cloud-redis",
- u"google-cloud-redis Documentation",
- [author],
- 1,
- )
+ (master_doc, "google-cloud-redis", "google-cloud-redis Documentation", [author], 1,)
]
# If true, show URL addresses after external links.
@@ -335,7 +329,7 @@
(
master_doc,
"google-cloud-redis",
- u"google-cloud-redis Documentation",
+ "google-cloud-redis Documentation",
author,
"google-cloud-redis",
"google-cloud-redis Library",
diff --git a/google/cloud/redis_v1/proto/cloud_redis.proto b/google/cloud/redis_v1/proto/cloud_redis.proto
deleted file mode 100644
index a45e9c0..0000000
--- a/google/cloud/redis_v1/proto/cloud_redis.proto
+++ /dev/null
@@ -1,634 +0,0 @@
-// Copyright 2020 Google LLC
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-syntax = "proto3";
-
-package google.cloud.redis.v1;
-
-import "google/api/annotations.proto";
-import "google/api/client.proto";
-import "google/api/field_behavior.proto";
-import "google/api/resource.proto";
-import "google/longrunning/operations.proto";
-import "google/protobuf/field_mask.proto";
-import "google/protobuf/timestamp.proto";
-
-option go_package = "google.golang.org/genproto/googleapis/cloud/redis/v1;redis";
-option java_multiple_files = true;
-option java_outer_classname = "CloudRedisServiceV1Proto";
-option java_package = "com.google.cloud.redis.v1";
-
-// Configures and manages Cloud Memorystore for Redis instances
-//
-// Google Cloud Memorystore for Redis v1
-//
-// The `redis.googleapis.com` service implements the Google Cloud Memorystore
-// for Redis API and defines the following resource model for managing Redis
-// instances:
-// * The service works with a collection of cloud projects, named: `/projects/*`
-// * Each project has a collection of available locations, named: `/locations/*`
-// * Each location has a collection of Redis instances, named: `/instances/*`
-// * As such, Redis instances are resources of the form:
-// `/projects/{project_id}/locations/{location_id}/instances/{instance_id}`
-//
-// Note that location_id must be referring to a GCP `region`; for example:
-// * `projects/redpepper-1290/locations/us-central1/instances/my-redis`
-service CloudRedis {
- option (google.api.default_host) = "redis.googleapis.com";
- option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";
-
- // Lists all Redis instances owned by a project in either the specified
- // location (region) or all locations.
- //
- // The location should have the following format:
- //
- // * `projects/{project_id}/locations/{location_id}`
- //
- // If `location_id` is specified as `-` (wildcard), then all regions
- // available to the project are queried, and the results are aggregated.
- rpc ListInstances(ListInstancesRequest) returns (ListInstancesResponse) {
- option (google.api.http) = {
- get: "/v1/{parent=projects/*/locations/*}/instances"
- };
- option (google.api.method_signature) = "parent";
- }
-
- // Gets the details of a specific Redis instance.
- rpc GetInstance(GetInstanceRequest) returns (Instance) {
- option (google.api.http) = {
- get: "/v1/{name=projects/*/locations/*/instances/*}"
- };
- option (google.api.method_signature) = "name";
- }
-
- // Creates a Redis instance based on the specified tier and memory size.
- //
- // By default, the instance is accessible from the project's
- // [default network](https://cloud.google.com/vpc/docs/vpc).
- //
- // The creation is executed asynchronously and callers may check the returned
- // operation to track its progress. Once the operation is completed the Redis
- // instance will be fully functional. Completed longrunning.Operation will
- // contain the new instance object in the response field.
- //
- // The returned operation is automatically deleted after a few hours, so there
- // is no need to call DeleteOperation.
- rpc CreateInstance(CreateInstanceRequest) returns (google.longrunning.Operation) {
- option (google.api.http) = {
- post: "/v1/{parent=projects/*/locations/*}/instances"
- body: "instance"
- };
- option (google.api.method_signature) = "parent,instance_id,instance";
- option (google.longrunning.operation_info) = {
- response_type: "google.cloud.redis.v1.Instance"
- metadata_type: "google.cloud.redis.v1.OperationMetadata"
- };
- }
-
- // Updates the metadata and configuration of a specific Redis instance.
- //
- // Completed longrunning.Operation will contain the new instance object
- // in the response field. The returned operation is automatically deleted
- // after a few hours, so there is no need to call DeleteOperation.
- rpc UpdateInstance(UpdateInstanceRequest) returns (google.longrunning.Operation) {
- option (google.api.http) = {
- patch: "/v1/{instance.name=projects/*/locations/*/instances/*}"
- body: "instance"
- };
- option (google.api.method_signature) = "update_mask,instance";
- option (google.longrunning.operation_info) = {
- response_type: "google.cloud.redis.v1.Instance"
- metadata_type: "google.cloud.redis.v1.OperationMetadata"
- };
- }
-
- // Upgrades Redis instance to the newer Redis version specified in the
- // request.
- rpc UpgradeInstance(UpgradeInstanceRequest) returns (google.longrunning.Operation) {
- option (google.api.http) = {
- post: "/v1/{name=projects/*/locations/*/instances/*}:upgrade"
- body: "*"
- };
- option (google.api.method_signature) = "name,redis_version";
- option (google.longrunning.operation_info) = {
- response_type: "google.cloud.redis.v1.Instance"
- metadata_type: "google.cloud.redis.v1.OperationMetadata"
- };
- }
-
- // Import a Redis RDB snapshot file from Cloud Storage into a Redis instance.
- //
- // Redis may stop serving during this operation. Instance state will be
- // IMPORTING for entire operation. When complete, the instance will contain
- // only data from the imported file.
- //
- // The returned operation is automatically deleted after a few hours, so
- // there is no need to call DeleteOperation.
- rpc ImportInstance(ImportInstanceRequest) returns (google.longrunning.Operation) {
- option (google.api.http) = {
- post: "/v1/{name=projects/*/locations/*/instances/*}:import"
- body: "*"
- };
- option (google.api.method_signature) = "name,input_config";
- option (google.longrunning.operation_info) = {
- response_type: "google.cloud.redis.v1.Instance"
- metadata_type: "google.cloud.redis.v1.OperationMetadata"
- };
- }
-
- // Export Redis instance data into a Redis RDB format file in Cloud Storage.
- //
- // Redis will continue serving during this operation.
- //
- // The returned operation is automatically deleted after a few hours, so
- // there is no need to call DeleteOperation.
- rpc ExportInstance(ExportInstanceRequest) returns (google.longrunning.Operation) {
- option (google.api.http) = {
- post: "/v1/{name=projects/*/locations/*/instances/*}:export"
- body: "*"
- };
- option (google.api.method_signature) = "name,output_config";
- option (google.longrunning.operation_info) = {
- response_type: "google.cloud.redis.v1.Instance"
- metadata_type: "google.cloud.redis.v1.OperationMetadata"
- };
- }
-
- // Initiates a failover of the master node to current replica node for a
- // specific STANDARD tier Cloud Memorystore for Redis instance.
- rpc FailoverInstance(FailoverInstanceRequest) returns (google.longrunning.Operation) {
- option (google.api.http) = {
- post: "/v1/{name=projects/*/locations/*/instances/*}:failover"
- body: "*"
- };
- option (google.api.method_signature) = "name,data_protection_mode";
- option (google.longrunning.operation_info) = {
- response_type: "google.cloud.redis.v1.Instance"
- metadata_type: "google.cloud.redis.v1.OperationMetadata"
- };
- }
-
- // Deletes a specific Redis instance. Instance stops serving and data is
- // deleted.
- rpc DeleteInstance(DeleteInstanceRequest) returns (google.longrunning.Operation) {
- option (google.api.http) = {
- delete: "/v1/{name=projects/*/locations/*/instances/*}"
- };
- option (google.api.method_signature) = "name";
- option (google.longrunning.operation_info) = {
- response_type: "google.protobuf.Empty"
- metadata_type: "google.cloud.redis.v1.OperationMetadata"
- };
- }
-}
-
-// A Google Cloud Redis instance.
-message Instance {
- option (google.api.resource) = {
- type: "redis.googleapis.com/Instance"
- pattern: "projects/{project}/locations/{location}/instances/{instance}"
- };
-
- // Represents the different states of a Redis instance.
- enum State {
- // Not set.
- STATE_UNSPECIFIED = 0;
-
- // Redis instance is being created.
- CREATING = 1;
-
- // Redis instance has been created and is fully usable.
- READY = 2;
-
- // Redis instance configuration is being updated. Certain kinds of updates
- // may cause the instance to become unusable while the update is in
- // progress.
- UPDATING = 3;
-
- // Redis instance is being deleted.
- DELETING = 4;
-
- // Redis instance is being repaired and may be unusable.
- REPAIRING = 5;
-
- // Maintenance is being performed on this Redis instance.
- MAINTENANCE = 6;
-
- // Redis instance is importing data (availability may be affected).
- IMPORTING = 8;
-
- // Redis instance is failing over (availability may be affected).
- FAILING_OVER = 9;
- }
-
- // Available service tiers to choose from
- enum Tier {
- // Not set.
- TIER_UNSPECIFIED = 0;
-
- // BASIC tier: standalone instance
- BASIC = 1;
-
- // STANDARD_HA tier: highly available primary/replica instances
- STANDARD_HA = 3;
- }
-
- // Available connection modes.
- enum ConnectMode {
- // Not set.
- CONNECT_MODE_UNSPECIFIED = 0;
-
- // Connect via direct peering to the Memorystore for Redis hosted service.
- DIRECT_PEERING = 1;
-
- // Connect your Memorystore for Redis instance using Private Service
- // Access. Private services access provides an IP address range for multiple
- // Google Cloud services, including Memorystore.
- PRIVATE_SERVICE_ACCESS = 2;
- }
-
- // Required. Unique name of the resource in this scope including project and
- // location using the form:
- // `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
- //
- // Note: Redis instances are managed and addressed at regional level so
- // location_id here refers to a GCP region; however, users may choose which
- // specific zone (or collection of zones for cross-zone instances) an instance
- // should be provisioned in. Refer to [location_id][google.cloud.redis.v1.Instance.location_id] and
- // [alternative_location_id][google.cloud.redis.v1.Instance.alternative_location_id] fields for more details.
- string name = 1 [(google.api.field_behavior) = REQUIRED];
-
- // An arbitrary and optional user-provided name for the instance.
- string display_name = 2;
-
- // Resource labels to represent user provided metadata
- map labels = 3;
-
- // Optional. The zone where the instance will be provisioned. If not provided,
- // the service will choose a zone for the instance. For STANDARD_HA tier,
- // instances will be created across two zones for protection against zonal
- // failures. If [alternative_location_id][google.cloud.redis.v1.Instance.alternative_location_id] is also provided, it must be
- // different from [location_id][google.cloud.redis.v1.Instance.location_id].
- string location_id = 4 [(google.api.field_behavior) = OPTIONAL];
-
- // Optional. Only applicable to STANDARD_HA tier which protects the instance
- // against zonal failures by provisioning it across two zones. If provided, it
- // must be a different zone from the one provided in [location_id][google.cloud.redis.v1.Instance.location_id].
- string alternative_location_id = 5 [(google.api.field_behavior) = OPTIONAL];
-
- // Optional. The version of Redis software.
- // If not provided, latest supported version will be used. Currently, the
- // supported values are:
- //
- // * `REDIS_3_2` for Redis 3.2 compatibility
- // * `REDIS_4_0` for Redis 4.0 compatibility (default)
- // * `REDIS_5_0` for Redis 5.0 compatibility
- string redis_version = 7 [(google.api.field_behavior) = OPTIONAL];
-
- // Optional. The CIDR range of internal addresses that are reserved for this
- // instance. If not provided, the service will choose an unused /29 block,
- // for example, 10.0.0.0/29 or 192.168.0.0/29. Ranges must be unique
- // and non-overlapping with existing subnets in an authorized network.
- string reserved_ip_range = 9 [(google.api.field_behavior) = OPTIONAL];
-
- // Output only. Hostname or IP address of the exposed Redis endpoint used by
- // clients to connect to the service.
- string host = 10 [(google.api.field_behavior) = OUTPUT_ONLY];
-
- // Output only. The port number of the exposed Redis endpoint.
- int32 port = 11 [(google.api.field_behavior) = OUTPUT_ONLY];
-
- // Output only. The current zone where the Redis endpoint is placed. For Basic
- // Tier instances, this will always be the same as the [location_id][google.cloud.redis.v1.Instance.location_id]
- // provided by the user at creation time. For Standard Tier instances,
- // this can be either [location_id][google.cloud.redis.v1.Instance.location_id] or [alternative_location_id][google.cloud.redis.v1.Instance.alternative_location_id] and can
- // change after a failover event.
- string current_location_id = 12 [(google.api.field_behavior) = OUTPUT_ONLY];
-
- // Output only. The time the instance was created.
- google.protobuf.Timestamp create_time = 13 [(google.api.field_behavior) = OUTPUT_ONLY];
-
- // Output only. The current state of this instance.
- State state = 14 [(google.api.field_behavior) = OUTPUT_ONLY];
-
- // Output only. Additional information about the current status of this
- // instance, if available.
- string status_message = 15 [(google.api.field_behavior) = OUTPUT_ONLY];
-
- // Optional. Redis configuration parameters, according to
- // http://redis.io/topics/config. Currently, the only supported parameters
- // are:
- //
- // Redis version 3.2 and newer:
- //
- // * maxmemory-policy
- // * notify-keyspace-events
- //
- // Redis version 4.0 and newer:
- //
- // * activedefrag
- // * lfu-decay-time
- // * lfu-log-factor
- // * maxmemory-gb
- //
- // Redis version 5.0 and newer:
- //
- // * stream-node-max-bytes
- // * stream-node-max-entries
- map redis_configs = 16 [(google.api.field_behavior) = OPTIONAL];
-
- // Required. The service tier of the instance.
- Tier tier = 17 [(google.api.field_behavior) = REQUIRED];
-
- // Required. Redis memory size in GiB.
- int32 memory_size_gb = 18 [(google.api.field_behavior) = REQUIRED];
-
- // Optional. The full name of the Google Compute Engine
- // [network](https://cloud.google.com/vpc/docs/vpc) to which the
- // instance is connected. If left unspecified, the `default` network
- // will be used.
- string authorized_network = 20 [(google.api.field_behavior) = OPTIONAL];
-
- // Output only. Cloud IAM identity used by import / export operations to
- // transfer data to/from Cloud Storage. Format is
- // "serviceAccount:". The value may change over time
- // for a given instance so should be checked before each import/export
- // operation.
- string persistence_iam_identity = 21 [(google.api.field_behavior) = OUTPUT_ONLY];
-
- // Optional. The network connect mode of the Redis instance.
- // If not provided, the connect mode defaults to DIRECT_PEERING.
- ConnectMode connect_mode = 22 [(google.api.field_behavior) = OPTIONAL];
-}
-
-// Request for [ListInstances][google.cloud.redis.v1.CloudRedis.ListInstances].
-message ListInstancesRequest {
- // Required. The resource name of the instance location using the form:
- // `projects/{project_id}/locations/{location_id}`
- // where `location_id` refers to a GCP region.
- string parent = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "locations.googleapis.com/Location"
- }
- ];
-
- // The maximum number of items to return.
- //
- // If not specified, a default value of 1000 will be used by the service.
- // Regardless of the page_size value, the response may include a partial list
- // and a caller should only rely on response's
- // [`next_page_token`][google.cloud.redis.v1.ListInstancesResponse.next_page_token]
- // to determine if there are more instances left to be queried.
- int32 page_size = 2;
-
- // The `next_page_token` value returned from a previous
- // [ListInstances][google.cloud.redis.v1.CloudRedis.ListInstances] request, if any.
- string page_token = 3;
-}
-
-// Response for [ListInstances][google.cloud.redis.v1.CloudRedis.ListInstances].
-message ListInstancesResponse {
- // A list of Redis instances in the project in the specified location,
- // or across all locations.
- //
- // If the `location_id` in the parent field of the request is "-", all regions
- // available to the project are queried, and the results aggregated.
- // If in such an aggregated query a location is unavailable, a dummy Redis
- // entry is included in the response with the `name` field set to a value of
- // the form `projects/{project_id}/locations/{location_id}/instances/`- and
- // the `status` field set to ERROR and `status_message` field set to "location
- // not available for ListInstances".
- repeated Instance instances = 1;
-
- // Token to retrieve the next page of results, or empty if there are no more
- // results in the list.
- string next_page_token = 2;
-
- // Locations that could not be reached.
- repeated string unreachable = 3;
-}
-
-// Request for [GetInstance][google.cloud.redis.v1.CloudRedis.GetInstance].
-message GetInstanceRequest {
- // Required. Redis instance resource name using the form:
- // `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
- // where `location_id` refers to a GCP region.
- string name = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "redis.googleapis.com/Instance"
- }
- ];
-}
-
-// Request for [CreateInstance][google.cloud.redis.v1.CloudRedis.CreateInstance].
-message CreateInstanceRequest {
- // Required. The resource name of the instance location using the form:
- // `projects/{project_id}/locations/{location_id}`
- // where `location_id` refers to a GCP region.
- string parent = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "locations.googleapis.com/Location"
- }
- ];
-
- // Required. The logical name of the Redis instance in the customer project
- // with the following restrictions:
- //
- // * Must contain only lowercase letters, numbers, and hyphens.
- // * Must start with a letter.
- // * Must be between 1-40 characters.
- // * Must end with a number or a letter.
- // * Must be unique within the customer project / location
- string instance_id = 2 [(google.api.field_behavior) = REQUIRED];
-
- // Required. A Redis [Instance] resource
- Instance instance = 3 [(google.api.field_behavior) = REQUIRED];
-}
-
-// Request for [UpdateInstance][google.cloud.redis.v1.CloudRedis.UpdateInstance].
-message UpdateInstanceRequest {
- // Required. Mask of fields to update. At least one path must be supplied in
- // this field. The elements of the repeated paths field may only include these
- // fields from [Instance][google.cloud.redis.v1.Instance]:
- //
- // * `displayName`
- // * `labels`
- // * `memorySizeGb`
- // * `redisConfig`
- google.protobuf.FieldMask update_mask = 1 [(google.api.field_behavior) = REQUIRED];
-
- // Required. Update description.
- // Only fields specified in update_mask are updated.
- Instance instance = 2 [(google.api.field_behavior) = REQUIRED];
-}
-
-// Request for [UpgradeInstance][google.cloud.redis.v1.CloudRedis.UpgradeInstance].
-message UpgradeInstanceRequest {
- // Required. Redis instance resource name using the form:
- // `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
- // where `location_id` refers to a GCP region.
- string name = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "redis.googleapis.com/Instance"
- }
- ];
-
- // Required. Specifies the target version of Redis software to upgrade to.
- string redis_version = 2 [(google.api.field_behavior) = REQUIRED];
-}
-
-// Request for [DeleteInstance][google.cloud.redis.v1.CloudRedis.DeleteInstance].
-message DeleteInstanceRequest {
- // Required. Redis instance resource name using the form:
- // `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
- // where `location_id` refers to a GCP region.
- string name = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "redis.googleapis.com/Instance"
- }
- ];
-}
-
-// The Cloud Storage location for the input content
-message GcsSource {
- // Required. Source data URI. (e.g. 'gs://my_bucket/my_object').
- string uri = 1 [(google.api.field_behavior) = REQUIRED];
-}
-
-// The input content
-message InputConfig {
- // Required. Specify source location of input data
- oneof source {
- // Google Cloud Storage location where input content is located.
- GcsSource gcs_source = 1;
- }
-}
-
-// Request for [Import][google.cloud.redis.v1.CloudRedis.ImportInstance].
-message ImportInstanceRequest {
- // Required. Redis instance resource name using the form:
- // `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
- // where `location_id` refers to a GCP region.
- string name = 1 [(google.api.field_behavior) = REQUIRED];
-
- // Required. Specify data to be imported.
- InputConfig input_config = 3 [(google.api.field_behavior) = REQUIRED];
-}
-
-// The Cloud Storage location for the output content
-message GcsDestination {
- // Required. Data destination URI (e.g.
- // 'gs://my_bucket/my_object'). Existing files will be overwritten.
- string uri = 1 [(google.api.field_behavior) = REQUIRED];
-}
-
-// The output content
-message OutputConfig {
- // Required. Specify destination location of output data
- oneof destination {
- // Google Cloud Storage destination for output content.
- GcsDestination gcs_destination = 1;
- }
-}
-
-// Request for [Export][google.cloud.redis.v1.CloudRedis.ExportInstance].
-message ExportInstanceRequest {
- // Required. Redis instance resource name using the form:
- // `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
- // where `location_id` refers to a GCP region.
- string name = 1 [(google.api.field_behavior) = REQUIRED];
-
- // Required. Specify data to be exported.
- OutputConfig output_config = 3 [(google.api.field_behavior) = REQUIRED];
-}
-
-// Request for [Failover][google.cloud.redis.v1.CloudRedis.FailoverInstance].
-message FailoverInstanceRequest {
- // Specifies different modes of operation in relation to the data retention.
- enum DataProtectionMode {
- // Defaults to LIMITED_DATA_LOSS if a data protection mode is not
- // specified.
- DATA_PROTECTION_MODE_UNSPECIFIED = 0;
-
- // Instance failover will be protected with data loss control. More
- // specifically, the failover will only be performed if the current
- // replication offset diff between master and replica is under a certain
- // threshold.
- LIMITED_DATA_LOSS = 1;
-
- // Instance failover will be performed without data loss control.
- FORCE_DATA_LOSS = 2;
- }
-
- // Required. Redis instance resource name using the form:
- // `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
- // where `location_id` refers to a GCP region.
- string name = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "redis.googleapis.com/Instance"
- }
- ];
-
- // Optional. Available data protection modes that the user can choose. If it's
- // unspecified, data protection mode will be LIMITED_DATA_LOSS by default.
- DataProtectionMode data_protection_mode = 2 [(google.api.field_behavior) = OPTIONAL];
-}
-
-// Represents the v1 metadata of the long-running operation.
-message OperationMetadata {
- // Creation timestamp.
- google.protobuf.Timestamp create_time = 1;
-
- // End timestamp.
- google.protobuf.Timestamp end_time = 2;
-
- // Operation target.
- string target = 3;
-
- // Operation verb.
- string verb = 4;
-
- // Operation status details.
- string status_detail = 5;
-
- // Specifies if cancellation was requested for the operation.
- bool cancel_requested = 6;
-
- // API version.
- string api_version = 7;
-}
-
-// This location metadata represents additional configuration options for a
-// given location where a Redis instance may be created. All fields are output
-// only. It is returned as content of the
-// `google.cloud.location.Location.metadata` field.
-message LocationMetadata {
- // Output only. The set of available zones in the location. The map is keyed
- // by the lowercase ID of each zone, as defined by GCE. These keys can be
- // specified in `location_id` or `alternative_location_id` fields when
- // creating a Redis instance.
- map available_zones = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
-}
-
-// Defines specific information for a particular zone. Currently empty and
-// reserved for future use only.
-message ZoneMetadata {
-
-}
diff --git a/google/cloud/redis_v1/services/cloud_redis/transports/base.py b/google/cloud/redis_v1/services/cloud_redis/transports/base.py
index c72e2bd..5bcde3a 100644
--- a/google/cloud/redis_v1/services/cloud_redis/transports/base.py
+++ b/google/cloud/redis_v1/services/cloud_redis/transports/base.py
@@ -25,6 +25,7 @@
from google.api_core import retry as retries # type: ignore
from google.api_core import operations_v1 # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
+from google.oauth2 import service_account # type: ignore
from google.cloud.redis_v1.types import cloud_redis
from google.longrunning import operations_pb2 # type: ignore
@@ -45,8 +46,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class CloudRedisTransport(abc.ABC):
"""Abstract transport class for CloudRedis."""
@@ -64,6 +63,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -87,6 +87,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -96,7 +98,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -115,13 +117,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # TODO(busunkim): This method is in the base transport
# to avoid duplicating code across the transport classes. These functions
- # should be deleted once the minimum required versions of google-api-core
- # and google-auth are increased.
+ # should be deleted once the minimum required versions of google-auth is increased.
# TODO: Remove this function once google-auth >= 1.25.0 is required
@classmethod
@@ -142,27 +151,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/redis_v1/services/cloud_redis/transports/grpc.py b/google/cloud/redis_v1/services/cloud_redis/transports/grpc.py
index e06f851..ae03d50 100644
--- a/google/cloud/redis_v1/services/cloud_redis/transports/grpc.py
+++ b/google/cloud/redis_v1/services/cloud_redis/transports/grpc.py
@@ -79,6 +79,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -119,6 +120,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -172,6 +175,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -227,14 +231,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
diff --git a/google/cloud/redis_v1/services/cloud_redis/transports/grpc_asyncio.py b/google/cloud/redis_v1/services/cloud_redis/transports/grpc_asyncio.py
index 4ce602a..6108ecb 100644
--- a/google/cloud/redis_v1/services/cloud_redis/transports/grpc_asyncio.py
+++ b/google/cloud/redis_v1/services/cloud_redis/transports/grpc_asyncio.py
@@ -100,14 +100,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -125,6 +125,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -166,6 +167,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -218,6 +221,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
diff --git a/google/cloud/redis_v1beta1/proto/cloud_redis.proto b/google/cloud/redis_v1beta1/proto/cloud_redis.proto
deleted file mode 100644
index 3eb99d8..0000000
--- a/google/cloud/redis_v1beta1/proto/cloud_redis.proto
+++ /dev/null
@@ -1,610 +0,0 @@
-// Copyright 2020 Google LLC
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-syntax = "proto3";
-
-package google.cloud.redis.v1beta1;
-
-import "google/api/annotations.proto";
-import "google/api/client.proto";
-import "google/api/field_behavior.proto";
-import "google/api/resource.proto";
-import "google/longrunning/operations.proto";
-import "google/protobuf/field_mask.proto";
-import "google/protobuf/timestamp.proto";
-
-option go_package = "google.golang.org/genproto/googleapis/cloud/redis/v1beta1;redis";
-option java_multiple_files = true;
-option java_outer_classname = "CloudRedisServiceBetaProto";
-option java_package = "com.google.cloud.redis.v1beta1";
-
-// Configures and manages Cloud Memorystore for Redis instances
-//
-// Google Cloud Memorystore for Redis v1beta1
-//
-// The `redis.googleapis.com` service implements the Google Cloud Memorystore
-// for Redis API and defines the following resource model for managing Redis
-// instances:
-// * The service works with a collection of cloud projects, named: `/projects/*`
-// * Each project has a collection of available locations, named: `/locations/*`
-// * Each location has a collection of Redis instances, named: `/instances/*`
-// * As such, Redis instances are resources of the form:
-// `/projects/{project_id}/locations/{location_id}/instances/{instance_id}`
-//
-// Note that location_id must be refering to a GCP `region`; for example:
-// * `projects/redpepper-1290/locations/us-central1/instances/my-redis`
-service CloudRedis {
- option (google.api.default_host) = "redis.googleapis.com";
- option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";
-
- // Lists all Redis instances owned by a project in either the specified
- // location (region) or all locations.
- //
- // The location should have the following format:
- //
- // * `projects/{project_id}/locations/{location_id}`
- //
- // If `location_id` is specified as `-` (wildcard), then all regions
- // available to the project are queried, and the results are aggregated.
- rpc ListInstances(ListInstancesRequest) returns (ListInstancesResponse) {
- option (google.api.http) = {
- get: "/v1beta1/{parent=projects/*/locations/*}/instances"
- };
- option (google.api.method_signature) = "parent";
- }
-
- // Gets the details of a specific Redis instance.
- rpc GetInstance(GetInstanceRequest) returns (Instance) {
- option (google.api.http) = {
- get: "/v1beta1/{name=projects/*/locations/*/instances/*}"
- };
- option (google.api.method_signature) = "name";
- }
-
- // Creates a Redis instance based on the specified tier and memory size.
- //
- // By default, the instance is accessible from the project's
- // [default network](https://cloud.google.com/vpc/docs/vpc).
- //
- // The creation is executed asynchronously and callers may check the returned
- // operation to track its progress. Once the operation is completed the Redis
- // instance will be fully functional. Completed longrunning.Operation will
- // contain the new instance object in the response field.
- //
- // The returned operation is automatically deleted after a few hours, so there
- // is no need to call DeleteOperation.
- rpc CreateInstance(CreateInstanceRequest) returns (google.longrunning.Operation) {
- option (google.api.http) = {
- post: "/v1beta1/{parent=projects/*/locations/*}/instances"
- body: "instance"
- };
- option (google.api.method_signature) = "parent,instance_id,instance";
- option (google.longrunning.operation_info) = {
- response_type: "google.cloud.redis.v1beta1.Instance"
- metadata_type: "google.protobuf.Any"
- };
- }
-
- // Updates the metadata and configuration of a specific Redis instance.
- //
- // Completed longrunning.Operation will contain the new instance object
- // in the response field. The returned operation is automatically deleted
- // after a few hours, so there is no need to call DeleteOperation.
- rpc UpdateInstance(UpdateInstanceRequest) returns (google.longrunning.Operation) {
- option (google.api.http) = {
- patch: "/v1beta1/{instance.name=projects/*/locations/*/instances/*}"
- body: "instance"
- };
- option (google.api.method_signature) = "update_mask,instance";
- option (google.longrunning.operation_info) = {
- response_type: "google.cloud.redis.v1beta1.Instance"
- metadata_type: "google.protobuf.Any"
- };
- }
-
- // Upgrades Redis instance to the newer Redis version specified in the
- // request.
- rpc UpgradeInstance(UpgradeInstanceRequest) returns (google.longrunning.Operation) {
- option (google.api.http) = {
- post: "/v1beta1/{name=projects/*/locations/*/instances/*}:upgrade"
- body: "*"
- };
- option (google.api.method_signature) = "name,redis_version";
- option (google.longrunning.operation_info) = {
- response_type: "google.cloud.redis.v1beta1.Instance"
- metadata_type: "google.protobuf.Any"
- };
- }
-
- // Import a Redis RDB snapshot file from Cloud Storage into a Redis instance.
- //
- // Redis may stop serving during this operation. Instance state will be
- // IMPORTING for entire operation. When complete, the instance will contain
- // only data from the imported file.
- //
- // The returned operation is automatically deleted after a few hours, so
- // there is no need to call DeleteOperation.
- rpc ImportInstance(ImportInstanceRequest) returns (google.longrunning.Operation) {
- option (google.api.http) = {
- post: "/v1beta1/{name=projects/*/locations/*/instances/*}:import"
- body: "*"
- };
- option (google.api.method_signature) = "name,input_config";
- option (google.longrunning.operation_info) = {
- response_type: "google.cloud.redis.v1beta1.Instance"
- metadata_type: "google.protobuf.Any"
- };
- }
-
- // Export Redis instance data into a Redis RDB format file in Cloud Storage.
- //
- // Redis will continue serving during this operation.
- //
- // The returned operation is automatically deleted after a few hours, so
- // there is no need to call DeleteOperation.
- rpc ExportInstance(ExportInstanceRequest) returns (google.longrunning.Operation) {
- option (google.api.http) = {
- post: "/v1beta1/{name=projects/*/locations/*/instances/*}:export"
- body: "*"
- };
- option (google.api.method_signature) = "name,output_config";
- option (google.longrunning.operation_info) = {
- response_type: "google.cloud.redis.v1beta1.Instance"
- metadata_type: "google.protobuf.Any"
- };
- }
-
- // Initiates a failover of the master node to current replica node for a
- // specific STANDARD tier Cloud Memorystore for Redis instance.
- rpc FailoverInstance(FailoverInstanceRequest) returns (google.longrunning.Operation) {
- option (google.api.http) = {
- post: "/v1beta1/{name=projects/*/locations/*/instances/*}:failover"
- body: "*"
- };
- option (google.api.method_signature) = "name,data_protection_mode";
- option (google.longrunning.operation_info) = {
- response_type: "google.cloud.redis.v1beta1.Instance"
- metadata_type: "google.protobuf.Any"
- };
- }
-
- // Deletes a specific Redis instance. Instance stops serving and data is
- // deleted.
- rpc DeleteInstance(DeleteInstanceRequest) returns (google.longrunning.Operation) {
- option (google.api.http) = {
- delete: "/v1beta1/{name=projects/*/locations/*/instances/*}"
- };
- option (google.api.method_signature) = "name";
- option (google.longrunning.operation_info) = {
- response_type: "google.protobuf.Empty"
- metadata_type: "google.protobuf.Any"
- };
- }
-}
-
-// A Google Cloud Redis instance.
-message Instance {
- option (google.api.resource) = {
- type: "redis.googleapis.com/Instance"
- pattern: "projects/{project}/locations/{location}/instances/{instance}"
- };
-
- // Represents the different states of a Redis instance.
- enum State {
- // Not set.
- STATE_UNSPECIFIED = 0;
-
- // Redis instance is being created.
- CREATING = 1;
-
- // Redis instance has been created and is fully usable.
- READY = 2;
-
- // Redis instance configuration is being updated. Certain kinds of updates
- // may cause the instance to become unusable while the update is in
- // progress.
- UPDATING = 3;
-
- // Redis instance is being deleted.
- DELETING = 4;
-
- // Redis instance is being repaired and may be unusable.
- REPAIRING = 5;
-
- // Maintenance is being performed on this Redis instance.
- MAINTENANCE = 6;
-
- // Redis instance is importing data (availability may be affected).
- IMPORTING = 8;
-
- // Redis instance is failing over (availability may be affected).
- FAILING_OVER = 10;
- }
-
- // Available service tiers to choose from
- enum Tier {
- // Not set.
- TIER_UNSPECIFIED = 0;
-
- // BASIC tier: standalone instance
- BASIC = 1;
-
- // STANDARD_HA tier: highly available primary/replica instances
- STANDARD_HA = 3;
- }
-
- // Available connection modes.
- enum ConnectMode {
- // Not set.
- CONNECT_MODE_UNSPECIFIED = 0;
-
- // Connect via directly peering with memorystore redis hosted service.
- DIRECT_PEERING = 1;
-
- // Connect with google via private service access and share connection
- // across google managed services.
- PRIVATE_SERVICE_ACCESS = 2;
- }
-
- // Required. Unique name of the resource in this scope including project and
- // location using the form:
- // `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
- //
- // Note: Redis instances are managed and addressed at regional level so
- // location_id here refers to a GCP region; however, users may choose which
- // specific zone (or collection of zones for cross-zone instances) an instance
- // should be provisioned in. Refer to [location_id][google.cloud.redis.v1beta1.Instance.location_id] and
- // [alternative_location_id][google.cloud.redis.v1beta1.Instance.alternative_location_id] fields for more details.
- string name = 1 [(google.api.field_behavior) = REQUIRED];
-
- // An arbitrary and optional user-provided name for the instance.
- string display_name = 2;
-
- // Resource labels to represent user provided metadata
- map labels = 3;
-
- // Optional. The zone where the instance will be provisioned. If not provided,
- // the service will choose a zone for the instance. For STANDARD_HA tier,
- // instances will be created across two zones for protection against zonal
- // failures. If [alternative_location_id][google.cloud.redis.v1beta1.Instance.alternative_location_id] is also provided, it must be
- // different from [location_id][google.cloud.redis.v1beta1.Instance.location_id].
- string location_id = 4 [(google.api.field_behavior) = OPTIONAL];
-
- // Optional. Only applicable to STANDARD_HA tier which protects the instance
- // against zonal failures by provisioning it across two zones. If provided, it
- // must be a different zone from the one provided in [location_id][google.cloud.redis.v1beta1.Instance.location_id].
- string alternative_location_id = 5 [(google.api.field_behavior) = OPTIONAL];
-
- // Optional. The version of Redis software.
- // If not provided, latest supported version will be used. Currently, the
- // supported values are:
- //
- // * `REDIS_3_2` for Redis 3.2 compatibility
- // * `REDIS_4_0` for Redis 4.0 compatibility (default)
- // * `REDIS_5_0` for Redis 5.0 compatibility
- string redis_version = 7 [(google.api.field_behavior) = OPTIONAL];
-
- // Optional. The CIDR range of internal addresses that are reserved for this
- // instance. If not provided, the service will choose an unused /29 block,
- // for example, 10.0.0.0/29 or 192.168.0.0/29. Ranges must be unique
- // and non-overlapping with existing subnets in an authorized network.
- string reserved_ip_range = 9 [(google.api.field_behavior) = OPTIONAL];
-
- // Output only. Hostname or IP address of the exposed Redis endpoint used by
- // clients to connect to the service.
- string host = 10 [(google.api.field_behavior) = OUTPUT_ONLY];
-
- // Output only. The port number of the exposed Redis endpoint.
- int32 port = 11 [(google.api.field_behavior) = OUTPUT_ONLY];
-
- // Output only. The current zone where the Redis endpoint is placed. For Basic
- // Tier instances, this will always be the same as the [location_id][google.cloud.redis.v1beta1.Instance.location_id]
- // provided by the user at creation time. For Standard Tier instances,
- // this can be either [location_id][google.cloud.redis.v1beta1.Instance.location_id] or [alternative_location_id][google.cloud.redis.v1beta1.Instance.alternative_location_id] and can
- // change after a failover event.
- string current_location_id = 12 [(google.api.field_behavior) = OUTPUT_ONLY];
-
- // Output only. The time the instance was created.
- google.protobuf.Timestamp create_time = 13 [(google.api.field_behavior) = OUTPUT_ONLY];
-
- // Output only. The current state of this instance.
- State state = 14 [(google.api.field_behavior) = OUTPUT_ONLY];
-
- // Output only. Additional information about the current status of this
- // instance, if available.
- string status_message = 15 [(google.api.field_behavior) = OUTPUT_ONLY];
-
- // Optional. Redis configuration parameters, according to
- // http://redis.io/topics/config. Currently, the only supported parameters
- // are:
- //
- // Redis version 3.2 and newer:
- //
- // * maxmemory-policy
- // * notify-keyspace-events
- //
- // Redis version 4.0 and newer:
- //
- // * activedefrag
- // * lfu-decay-time
- // * lfu-log-factor
- // * maxmemory-gb
- //
- // Redis version 5.0 and newer:
- //
- // * stream-node-max-bytes
- // * stream-node-max-entries
- map redis_configs = 16 [(google.api.field_behavior) = OPTIONAL];
-
- // Required. The service tier of the instance.
- Tier tier = 17 [(google.api.field_behavior) = REQUIRED];
-
- // Required. Redis memory size in GiB.
- int32 memory_size_gb = 18 [(google.api.field_behavior) = REQUIRED];
-
- // Optional. The full name of the Google Compute Engine
- // [network](https://cloud.google.com/vpc/docs/vpc) to which the
- // instance is connected. If left unspecified, the `default` network
- // will be used.
- string authorized_network = 20 [(google.api.field_behavior) = OPTIONAL];
-
- // Output only. Cloud IAM identity used by import / export operations to
- // transfer data to/from Cloud Storage. Format is
- // "serviceAccount:". The value may change over time
- // for a given instance so should be checked before each import/export
- // operation.
- string persistence_iam_identity = 21 [(google.api.field_behavior) = OUTPUT_ONLY];
-
- // Optional. The connect mode of Redis instance.
- // If not provided, default one will be used.
- // Current default: DIRECT_PEERING.
- ConnectMode connect_mode = 22 [(google.api.field_behavior) = OPTIONAL];
-}
-
-// Request for [ListInstances][google.cloud.redis.v1beta1.CloudRedis.ListInstances].
-message ListInstancesRequest {
- // Required. The resource name of the instance location using the form:
- // `projects/{project_id}/locations/{location_id}`
- // where `location_id` refers to a GCP region.
- string parent = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "locations.googleapis.com/Location"
- }
- ];
-
- // The maximum number of items to return.
- //
- // If not specified, a default value of 1000 will be used by the service.
- // Regardless of the page_size value, the response may include a partial list
- // and a caller should only rely on response's
- // [`next_page_token`][google.cloud.redis.v1beta1.ListInstancesResponse.next_page_token]
- // to determine if there are more instances left to be queried.
- int32 page_size = 2;
-
- // The `next_page_token` value returned from a previous
- // [ListInstances][google.cloud.redis.v1beta1.CloudRedis.ListInstances] request, if any.
- string page_token = 3;
-}
-
-// Response for [ListInstances][google.cloud.redis.v1beta1.CloudRedis.ListInstances].
-message ListInstancesResponse {
- // A list of Redis instances in the project in the specified location,
- // or across all locations.
- //
- // If the `location_id` in the parent field of the request is "-", all regions
- // available to the project are queried, and the results aggregated.
- // If in such an aggregated query a location is unavailable, a dummy Redis
- // entry is included in the response with the `name` field set to a value of
- // the form `projects/{project_id}/locations/{location_id}/instances/`- and
- // the `status` field set to ERROR and `status_message` field set to "location
- // not available for ListInstances".
- repeated Instance instances = 1;
-
- // Token to retrieve the next page of results, or empty if there are no more
- // results in the list.
- string next_page_token = 2;
-
- // Locations that could not be reached.
- repeated string unreachable = 3;
-}
-
-// Request for [GetInstance][google.cloud.redis.v1beta1.CloudRedis.GetInstance].
-message GetInstanceRequest {
- // Required. Redis instance resource name using the form:
- // `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
- // where `location_id` refers to a GCP region.
- string name = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "redis.googleapis.com/Instance"
- }
- ];
-}
-
-// Request for [CreateInstance][google.cloud.redis.v1beta1.CloudRedis.CreateInstance].
-message CreateInstanceRequest {
- // Required. The resource name of the instance location using the form:
- // `projects/{project_id}/locations/{location_id}`
- // where `location_id` refers to a GCP region.
- string parent = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "locations.googleapis.com/Location"
- }
- ];
-
- // Required. The logical name of the Redis instance in the customer project
- // with the following restrictions:
- //
- // * Must contain only lowercase letters, numbers, and hyphens.
- // * Must start with a letter.
- // * Must be between 1-40 characters.
- // * Must end with a number or a letter.
- // * Must be unique within the customer project / location
- string instance_id = 2 [(google.api.field_behavior) = REQUIRED];
-
- // Required. A Redis [Instance] resource
- Instance instance = 3 [(google.api.field_behavior) = REQUIRED];
-}
-
-// Request for [UpdateInstance][google.cloud.redis.v1beta1.CloudRedis.UpdateInstance].
-message UpdateInstanceRequest {
- // Required. Mask of fields to update. At least one path must be supplied in
- // this field. The elements of the repeated paths field may only include these
- // fields from [Instance][google.cloud.redis.v1beta1.Instance]:
- //
- // * `displayName`
- // * `labels`
- // * `memorySizeGb`
- // * `redisConfig`
- google.protobuf.FieldMask update_mask = 1 [(google.api.field_behavior) = REQUIRED];
-
- // Required. Update description.
- // Only fields specified in update_mask are updated.
- Instance instance = 2 [(google.api.field_behavior) = REQUIRED];
-}
-
-// Request for [UpgradeInstance][google.cloud.redis.v1beta1.CloudRedis.UpgradeInstance].
-message UpgradeInstanceRequest {
- // Required. Redis instance resource name using the form:
- // `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
- // where `location_id` refers to a GCP region.
- string name = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "redis.googleapis.com/Instance"
- }
- ];
-
- // Required. Specifies the target version of Redis software to upgrade to.
- string redis_version = 2 [(google.api.field_behavior) = REQUIRED];
-}
-
-// Request for [DeleteInstance][google.cloud.redis.v1beta1.CloudRedis.DeleteInstance].
-message DeleteInstanceRequest {
- // Required. Redis instance resource name using the form:
- // `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
- // where `location_id` refers to a GCP region.
- string name = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "redis.googleapis.com/Instance"
- }
- ];
-}
-
-// The Cloud Storage location for the input content
-message GcsSource {
- // Required. Source data URI. (e.g. 'gs://my_bucket/my_object').
- string uri = 1 [(google.api.field_behavior) = REQUIRED];
-}
-
-// The input content
-message InputConfig {
- // Required. Specify source location of input data
- oneof source {
- // Google Cloud Storage location where input content is located.
- GcsSource gcs_source = 1;
- }
-}
-
-// Request for [Import][google.cloud.redis.v1beta1.CloudRedis.ImportInstance].
-message ImportInstanceRequest {
- // Required. Redis instance resource name using the form:
- // `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
- // where `location_id` refers to a GCP region.
- string name = 1 [(google.api.field_behavior) = REQUIRED];
-
- // Required. Specify data to be imported.
- InputConfig input_config = 3 [(google.api.field_behavior) = REQUIRED];
-}
-
-// The Cloud Storage location for the output content
-message GcsDestination {
- // Required. Data destination URI (e.g.
- // 'gs://my_bucket/my_object'). Existing files will be overwritten.
- string uri = 1 [(google.api.field_behavior) = REQUIRED];
-}
-
-// The output content
-message OutputConfig {
- // Required. Specify destination location of output data
- oneof destination {
- // Google Cloud Storage destination for output content.
- GcsDestination gcs_destination = 1;
- }
-}
-
-// Request for [Export][google.cloud.redis.v1beta1.CloudRedis.ExportInstance].
-message ExportInstanceRequest {
- // Required. Redis instance resource name using the form:
- // `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
- // where `location_id` refers to a GCP region.
- string name = 1 [(google.api.field_behavior) = REQUIRED];
-
- // Required. Specify data to be exported.
- OutputConfig output_config = 3 [(google.api.field_behavior) = REQUIRED];
-}
-
-// Request for [Failover][google.cloud.redis.v1beta1.CloudRedis.FailoverInstance].
-message FailoverInstanceRequest {
- // Specifies different modes of operation in relation to the data retention.
- enum DataProtectionMode {
- // Defaults to LIMITED_DATA_LOSS if a data protection mode is not
- // specified.
- DATA_PROTECTION_MODE_UNSPECIFIED = 0;
-
- // Instance failover will be protected with data loss control. More
- // specifically, the failover will only be performed if the current
- // replication offset diff between master and replica is under a certain
- // threshold.
- LIMITED_DATA_LOSS = 1;
-
- // Instance failover will be performed without data loss control.
- FORCE_DATA_LOSS = 2;
- }
-
- // Required. Redis instance resource name using the form:
- // `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
- // where `location_id` refers to a GCP region.
- string name = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "redis.googleapis.com/Instance"
- }
- ];
-
- // Optional. Available data protection modes that the user can choose. If it's
- // unspecified, data protection mode will be LIMITED_DATA_LOSS by default.
- DataProtectionMode data_protection_mode = 2 [(google.api.field_behavior) = OPTIONAL];
-}
-
-// This location metadata represents additional configuration options for a
-// given location where a Redis instance may be created. All fields are output
-// only. It is returned as content of the
-// `google.cloud.location.Location.metadata` field.
-message LocationMetadata {
- // Output only. The set of available zones in the location. The map is keyed
- // by the lowercase ID of each zone, as defined by GCE. These keys can be
- // specified in `location_id` or `alternative_location_id` fields when
- // creating a Redis instance.
- map available_zones = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
-}
-
-// Defines specific information for a particular zone. Currently empty and
-// reserved for future use only.
-message ZoneMetadata {
-
-}
diff --git a/google/cloud/redis_v1beta1/services/cloud_redis/transports/base.py b/google/cloud/redis_v1beta1/services/cloud_redis/transports/base.py
index 5924854..5b58f51 100644
--- a/google/cloud/redis_v1beta1/services/cloud_redis/transports/base.py
+++ b/google/cloud/redis_v1beta1/services/cloud_redis/transports/base.py
@@ -25,6 +25,7 @@
from google.api_core import retry as retries # type: ignore
from google.api_core import operations_v1 # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
+from google.oauth2 import service_account # type: ignore
from google.cloud.redis_v1beta1.types import cloud_redis
from google.longrunning import operations_pb2 # type: ignore
@@ -45,8 +46,6 @@
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None
-_API_CORE_VERSION = google.api_core.__version__
-
class CloudRedisTransport(abc.ABC):
"""Abstract transport class for CloudRedis."""
@@ -64,6 +63,7 @@ def __init__(
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
@@ -87,6 +87,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
@@ -96,7 +98,7 @@ def __init__(
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
@@ -115,13 +117,20 @@ def __init__(
**scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
- # TODO(busunkim): These two class methods are in the base transport
+ # TODO(busunkim): This method is in the base transport
# to avoid duplicating code across the transport classes. These functions
- # should be deleted once the minimum required versions of google-api-core
- # and google-auth are increased.
+ # should be deleted once the minimum required versions of google-auth is increased.
# TODO: Remove this function once google-auth >= 1.25.0 is required
@classmethod
@@ -142,27 +151,6 @@ def _get_scopes_kwargs(
return scopes_kwargs
- # TODO: Remove this function once google-api-core >= 1.26.0 is required
- @classmethod
- def _get_self_signed_jwt_kwargs(
- cls, host: str, scopes: Optional[Sequence[str]]
- ) -> Dict[str, Union[Optional[Sequence[str]], str]]:
- """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
-
- self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
-
- if _API_CORE_VERSION and (
- packaging.version.parse(_API_CORE_VERSION)
- >= packaging.version.parse("1.26.0")
- ):
- self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
- self_signed_jwt_kwargs["scopes"] = scopes
- self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
- else:
- self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
-
- return self_signed_jwt_kwargs
-
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
diff --git a/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc.py b/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc.py
index 433a8d6..590db8f 100644
--- a/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc.py
+++ b/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc.py
@@ -79,6 +79,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -119,6 +120,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -172,6 +175,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -227,14 +231,14 @@ def create_channel(
and ``credentials_file`` are passed.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
diff --git a/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc_asyncio.py b/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc_asyncio.py
index 4dedbd9..764457c 100644
--- a/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc_asyncio.py
+++ b/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc_asyncio.py
@@ -100,14 +100,14 @@ def create_channel(
aio.Channel: A gRPC AsyncIO channel object.
"""
- self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
-
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
quota_project_id=quota_project_id,
- **self_signed_jwt_kwargs,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -125,6 +125,7 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
@@ -166,6 +167,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -218,6 +221,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
diff --git a/setup.py b/setup.py
index b8a06eb..457a3c6 100644
--- a/setup.py
+++ b/setup.py
@@ -22,14 +22,14 @@
name = "google-cloud-redis"
description = "Google Cloud Memorystore for Redis API client library"
-version = "2.1.1"
+version = "2.2.0"
# Should be one of:
# 'Development Status :: 3 - Alpha'
# 'Development Status :: 4 - Beta'
# 'Development Status :: 5 - Production/Stable'
release_status = "Development Status :: 5 - Production/Stable"
dependencies = [
- "google-api-core[grpc] >= 1.22.2, < 2.0.0dev",
+ "google-api-core[grpc] >= 1.26.0, <2.0.0dev",
"proto-plus >= 1.4.0",
"packaging >= 14.3",
]
diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt
index ce07c30..add8f1e 100644
--- a/testing/constraints-3.6.txt
+++ b/testing/constraints-3.6.txt
@@ -5,7 +5,7 @@
#
# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev",
# Then this file should have foo==1.14.0
-google-api-core==1.22.2
+google-api-core==1.26.0
proto-plus==1.4.0
libcst==0.2.5
packaging==14.3
diff --git a/tests/unit/gapic/redis_v1/test_cloud_redis.py b/tests/unit/gapic/redis_v1/test_cloud_redis.py
index 15de5cb..45c3f42 100644
--- a/tests/unit/gapic/redis_v1/test_cloud_redis.py
+++ b/tests/unit/gapic/redis_v1/test_cloud_redis.py
@@ -38,7 +38,6 @@
from google.cloud.redis_v1.services.cloud_redis import CloudRedisClient
from google.cloud.redis_v1.services.cloud_redis import pagers
from google.cloud.redis_v1.services.cloud_redis import transports
-from google.cloud.redis_v1.services.cloud_redis.transports.base import _API_CORE_VERSION
from google.cloud.redis_v1.services.cloud_redis.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -50,8 +49,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -62,16 +62,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -129,6 +119,34 @@ def test_cloud_redis_client_from_service_account_info(client_class):
assert client.transport._host == "redis.googleapis.com:443"
+@pytest.mark.parametrize("client_class", [CloudRedisClient, CloudRedisAsyncClient,])
+def test_cloud_redis_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.CloudRedisGrpcTransport, "grpc"),
+ (transports.CloudRedisGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_cloud_redis_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize("client_class", [CloudRedisClient, CloudRedisAsyncClient,])
def test_cloud_redis_client_from_service_account_file(client_class):
creds = ga_credentials.AnonymousCredentials()
@@ -2778,7 +2796,6 @@ def test_cloud_redis_transport_auth_adc_old_google_auth(transport_class):
(transports.CloudRedisGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_cloud_redis_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -2807,79 +2824,6 @@ def test_cloud_redis_transport_create_channel(transport_class, grpc_helpers):
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.CloudRedisGrpcTransport, grpc_helpers),
- (transports.CloudRedisGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_cloud_redis_transport_create_channel_old_api_core(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "redis.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=("https://www.googleapis.com/auth/cloud-platform",),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.CloudRedisGrpcTransport, grpc_helpers),
- (transports.CloudRedisGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_cloud_redis_transport_create_channel_user_scopes(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "redis.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[transports.CloudRedisGrpcTransport, transports.CloudRedisGrpcAsyncIOTransport],
@@ -2899,7 +2843,7 @@ def test_cloud_redis_grpc_transport_client_cert_source_for_mtls(transport_class)
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -3003,7 +2947,7 @@ def test_cloud_redis_transport_channel_mtls_with_client_cert_source(transport_cl
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -3047,7 +2991,7 @@ def test_cloud_redis_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
diff --git a/tests/unit/gapic/redis_v1beta1/test_cloud_redis.py b/tests/unit/gapic/redis_v1beta1/test_cloud_redis.py
index 77dad97..1d15290 100644
--- a/tests/unit/gapic/redis_v1beta1/test_cloud_redis.py
+++ b/tests/unit/gapic/redis_v1beta1/test_cloud_redis.py
@@ -38,9 +38,6 @@
from google.cloud.redis_v1beta1.services.cloud_redis import CloudRedisClient
from google.cloud.redis_v1beta1.services.cloud_redis import pagers
from google.cloud.redis_v1beta1.services.cloud_redis import transports
-from google.cloud.redis_v1beta1.services.cloud_redis.transports.base import (
- _API_CORE_VERSION,
-)
from google.cloud.redis_v1beta1.services.cloud_redis.transports.base import (
_GOOGLE_AUTH_VERSION,
)
@@ -53,8 +50,9 @@
import google.auth
-# TODO(busunkim): Once google-api-core >= 1.26.0 is required:
-# - Delete all the api-core and auth "less than" test cases
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
@@ -65,16 +63,6 @@
reason="This test requires google-auth >= 1.25.0",
)
-requires_api_core_lt_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core < 1.26.0",
-)
-
-requires_api_core_gte_1_26_0 = pytest.mark.skipif(
- packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"),
- reason="This test requires google-api-core >= 1.26.0",
-)
-
def client_cert_source_callback():
return b"cert bytes", b"key bytes"
@@ -132,6 +120,34 @@ def test_cloud_redis_client_from_service_account_info(client_class):
assert client.transport._host == "redis.googleapis.com:443"
+@pytest.mark.parametrize("client_class", [CloudRedisClient, CloudRedisAsyncClient,])
+def test_cloud_redis_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.CloudRedisGrpcTransport, "grpc"),
+ (transports.CloudRedisGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_cloud_redis_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize("client_class", [CloudRedisClient, CloudRedisAsyncClient,])
def test_cloud_redis_client_from_service_account_file(client_class):
creds = ga_credentials.AnonymousCredentials()
@@ -2781,7 +2797,6 @@ def test_cloud_redis_transport_auth_adc_old_google_auth(transport_class):
(transports.CloudRedisGrpcAsyncIOTransport, grpc_helpers_async),
],
)
-@requires_api_core_gte_1_26_0
def test_cloud_redis_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
@@ -2810,79 +2825,6 @@ def test_cloud_redis_transport_create_channel(transport_class, grpc_helpers):
)
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.CloudRedisGrpcTransport, grpc_helpers),
- (transports.CloudRedisGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_cloud_redis_transport_create_channel_old_api_core(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus")
-
- create_channel.assert_called_with(
- "redis.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=("https://www.googleapis.com/auth/cloud-platform",),
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.CloudRedisGrpcTransport, grpc_helpers),
- (transports.CloudRedisGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-@requires_api_core_lt_1_26_0
-def test_cloud_redis_transport_create_channel_user_scopes(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
-
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "redis.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- scopes=["1", "2"],
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
@pytest.mark.parametrize(
"transport_class",
[transports.CloudRedisGrpcTransport, transports.CloudRedisGrpcAsyncIOTransport],
@@ -2902,7 +2844,7 @@ def test_cloud_redis_grpc_transport_client_cert_source_for_mtls(transport_class)
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -3006,7 +2948,7 @@ def test_cloud_redis_transport_channel_mtls_with_client_cert_source(transport_cl
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -3050,7 +2992,7 @@ def test_cloud_redis_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[