Skip to content
This repository was archived by the owner on Sep 5, 2023. It is now read-only.

fix: Add missing fields for TLS and Maintenance Window features #147

Merged
merged 2 commits into from
Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions google/cloud/redis_v1beta1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,24 @@
from .types.cloud_redis import FailoverInstanceRequest
from .types.cloud_redis import GcsDestination
from .types.cloud_redis import GcsSource
from .types.cloud_redis import GetInstanceAuthStringRequest
from .types.cloud_redis import GetInstanceRequest
from .types.cloud_redis import ImportInstanceRequest
from .types.cloud_redis import InputConfig
from .types.cloud_redis import Instance
from .types.cloud_redis import InstanceAuthString
from .types.cloud_redis import ListInstancesRequest
from .types.cloud_redis import ListInstancesResponse
from .types.cloud_redis import LocationMetadata
from .types.cloud_redis import MaintenancePolicy
from .types.cloud_redis import MaintenanceSchedule
from .types.cloud_redis import NodeInfo
from .types.cloud_redis import OutputConfig
from .types.cloud_redis import RescheduleMaintenanceRequest
from .types.cloud_redis import TlsCertificate
from .types.cloud_redis import UpdateInstanceRequest
from .types.cloud_redis import UpgradeInstanceRequest
from .types.cloud_redis import WeeklyMaintenanceWindow
from .types.cloud_redis import ZoneMetadata

__all__ = (
Expand All @@ -45,16 +52,23 @@
"FailoverInstanceRequest",
"GcsDestination",
"GcsSource",
"GetInstanceAuthStringRequest",
"GetInstanceRequest",
"ImportInstanceRequest",
"InputConfig",
"Instance",
"InstanceAuthString",
"ListInstancesRequest",
"ListInstancesResponse",
"LocationMetadata",
"MaintenancePolicy",
"MaintenanceSchedule",
"NodeInfo",
"OutputConfig",
"RescheduleMaintenanceRequest",
"TlsCertificate",
"UpdateInstanceRequest",
"UpgradeInstanceRequest",
"WeeklyMaintenanceWindow",
"ZoneMetadata",
)
20 changes: 20 additions & 0 deletions google/cloud/redis_v1beta1/gapic_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
"get_instance"
]
},
"GetInstanceAuthString": {
"methods": [
"get_instance_auth_string"
]
},
"ImportInstance": {
"methods": [
"import_instance"
Expand All @@ -45,6 +50,11 @@
"list_instances"
]
},
"RescheduleMaintenance": {
"methods": [
"reschedule_maintenance"
]
},
"UpdateInstance": {
"methods": [
"update_instance"
Expand Down Expand Up @@ -85,6 +95,11 @@
"get_instance"
]
},
"GetInstanceAuthString": {
"methods": [
"get_instance_auth_string"
]
},
"ImportInstance": {
"methods": [
"import_instance"
Expand All @@ -95,6 +110,11 @@
"list_instances"
]
},
"RescheduleMaintenance": {
"methods": [
"reschedule_maintenance"
]
},
"UpdateInstance": {
"methods": [
"update_instance"
Expand Down
180 changes: 179 additions & 1 deletion google/cloud/redis_v1beta1/services/cloud_redis/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ async def list_instances(
Returns:
google.cloud.redis_v1beta1.services.cloud_redis.pagers.ListInstancesAsyncPager:
Response for
[ListInstances][google.cloud.redis.v1beta1.CloudRedis.ListInstances].
[ListInstances][google.cloud.redis.v1beta1.CloudRedis.ListInstances].

Iterating over this object will yield results and
resolve additional pages automatically.
Expand Down Expand Up @@ -348,6 +348,79 @@ async def get_instance(
# Done; return the response.
return response

async def get_instance_auth_string(
self,
request: Union[cloud_redis.GetInstanceAuthStringRequest, dict] = None,
*,
name: str = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_redis.InstanceAuthString:
r"""Gets the AUTH string for a Redis instance. If AUTH is
not enabled for the instance the response will be empty.
This information is not included in the details returned
to GetInstance.

Args:
request (Union[google.cloud.redis_v1beta1.types.GetInstanceAuthStringRequest, dict]):
The request object. Request for
[GetInstanceAuthString][google.cloud.redis.v1beta1.CloudRedis.GetInstanceAuthString].
name (:class:`str`):
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.

This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.

Returns:
google.cloud.redis_v1beta1.types.InstanceAuthString:
Instance AUTH string details.
"""
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)

request = cloud_redis.GetInstanceAuthStringRequest(request)

# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.get_instance_auth_string,
default_timeout=600.0,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)

# Send the request.
response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)

# Done; return the response.
return response

async def create_instance(
self,
request: Union[cloud_redis.CreateInstanceRequest, dict] = None,
Expand Down Expand Up @@ -1059,6 +1132,111 @@ async def delete_instance(
# Done; return the response.
return response

async def reschedule_maintenance(
self,
request: Union[cloud_redis.RescheduleMaintenanceRequest, dict] = None,
*,
name: str = None,
reschedule_type: cloud_redis.RescheduleMaintenanceRequest.RescheduleType = None,
schedule_time: timestamp_pb2.Timestamp = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Reschedule maintenance for a given instance in a
given project and location.

Args:
request (Union[google.cloud.redis_v1beta1.types.RescheduleMaintenanceRequest, dict]):
The request object. Request for
[RescheduleMaintenance][google.cloud.redis.v1beta1.CloudRedis.RescheduleMaintenance].
name (:class:`str`):
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.

This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
reschedule_type (:class:`google.cloud.redis_v1beta1.types.RescheduleMaintenanceRequest.RescheduleType`):
Required. If reschedule type is SPECIFIC_TIME, must set
up schedule_time as well.

This corresponds to the ``reschedule_type`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
schedule_time (:class:`google.protobuf.timestamp_pb2.Timestamp`):
Optional. Timestamp when the maintenance shall be
rescheduled to if reschedule_type=SPECIFIC_TIME, in RFC
3339 format, for example ``2012-11-15T16:19:00.094Z``.

This corresponds to the ``schedule_time`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.

Returns:
google.api_core.operation_async.AsyncOperation:
An object representing a long-running operation.

The result type for the operation will be
:class:`google.cloud.redis_v1beta1.types.Instance` A
Google Cloud Redis instance.

"""
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name, reschedule_type, schedule_time])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)

request = cloud_redis.RescheduleMaintenanceRequest(request)

# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name
if reschedule_type is not None:
request.reschedule_type = reschedule_type
if schedule_time is not None:
request.schedule_time = schedule_time

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.reschedule_maintenance,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)

# Send the request.
response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)

# Wrap the response in an operation future.
response = operation_async.from_gapic(
response,
self._client._transport.operations_client,
cloud_redis.Instance,
metadata_type=any_pb2.Any,
)

# Done; return the response.
return response

async def __aenter__(self):
return self

Expand Down
Loading