@@ -642,3 +642,265 @@ def delete_instance(
642642 empty_pb2 .Empty ,
643643 metadata_type = cloud_redis_pb2 .OperationMetadata ,
644644 )
645+
646+ def import_instance (
647+ self ,
648+ name ,
649+ input_config ,
650+ retry = google .api_core .gapic_v1 .method .DEFAULT ,
651+ timeout = google .api_core .gapic_v1 .method .DEFAULT ,
652+ metadata = None ,
653+ ):
654+ """
655+ Import a Redis RDB snapshot file from GCS into a Redis instance.
656+
657+ Redis may stop serving during this operation. Instance state will be
658+ IMPORTING for entire operation. When complete, the instance will contain
659+ only data from the imported file.
660+
661+ The returned operation is automatically deleted after a few hours, so
662+ there is no need to call DeleteOperation.
663+
664+ Example:
665+ >>> from google.cloud import redis_v1
666+ >>>
667+ >>> client = redis_v1.CloudRedisClient()
668+ >>>
669+ >>> name = client.instance_path('[PROJECT]', '[LOCATION]', '[INSTANCE]')
670+ >>>
671+ >>> # TODO: Initialize `input_config`:
672+ >>> input_config = {}
673+ >>>
674+ >>> response = client.import_instance(name, input_config)
675+ >>>
676+ >>> def callback(operation_future):
677+ ... # Handle result.
678+ ... result = operation_future.result()
679+ >>>
680+ >>> response.add_done_callback(callback)
681+ >>>
682+ >>> # Handle metadata.
683+ >>> metadata = response.metadata()
684+
685+ Args:
686+ name (str): Required. Redis instance resource name using the form:
687+ ``projects/{project_id}/locations/{location_id}/instances/{instance_id}``
688+ where ``location_id`` refers to a GCP region
689+ input_config (Union[dict, ~google.cloud.redis_v1.types.InputConfig]): Required. Specify data to be imported.
690+
691+ If a dict is provided, it must be of the same form as the protobuf
692+ message :class:`~google.cloud.redis_v1.types.InputConfig`
693+ retry (Optional[google.api_core.retry.Retry]): A retry object used
694+ to retry requests. If ``None`` is specified, requests will not
695+ be retried.
696+ timeout (Optional[float]): The amount of time, in seconds, to wait
697+ for the request to complete. Note that if ``retry`` is
698+ specified, the timeout applies to each individual attempt.
699+ metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
700+ that is provided to the method.
701+
702+ Returns:
703+ A :class:`~google.cloud.redis_v1.types._OperationFuture` instance.
704+
705+ Raises:
706+ google.api_core.exceptions.GoogleAPICallError: If the request
707+ failed for any reason.
708+ google.api_core.exceptions.RetryError: If the request failed due
709+ to a retryable error and retry attempts failed.
710+ ValueError: If the parameters are invalid.
711+ """
712+ # Wrap the transport method to add retry and timeout logic.
713+ if "import_instance" not in self ._inner_api_calls :
714+ self ._inner_api_calls [
715+ "import_instance"
716+ ] = google .api_core .gapic_v1 .method .wrap_method (
717+ self .transport .import_instance ,
718+ default_retry = self ._method_configs ["ImportInstance" ].retry ,
719+ default_timeout = self ._method_configs ["ImportInstance" ].timeout ,
720+ client_info = self ._client_info ,
721+ )
722+
723+ request = cloud_redis_pb2 .ImportInstanceRequest (
724+ name = name , input_config = input_config
725+ )
726+ operation = self ._inner_api_calls ["import_instance" ](
727+ request , retry = retry , timeout = timeout , metadata = metadata
728+ )
729+ return google .api_core .operation .from_gapic (
730+ operation ,
731+ self .transport ._operations_client ,
732+ cloud_redis_pb2 .Instance ,
733+ metadata_type = cloud_redis_pb2 .OperationMetadata ,
734+ )
735+
736+ def export_instance (
737+ self ,
738+ name ,
739+ output_config ,
740+ retry = google .api_core .gapic_v1 .method .DEFAULT ,
741+ timeout = google .api_core .gapic_v1 .method .DEFAULT ,
742+ metadata = None ,
743+ ):
744+ """
745+ Export Redis instance data into a Redis RDB format file in GCS.
746+
747+ Redis will continue serving during this operation.
748+
749+ The returned operation is automatically deleted after a few hours, so
750+ there is no need to call DeleteOperation.
751+
752+ Example:
753+ >>> from google.cloud import redis_v1
754+ >>>
755+ >>> client = redis_v1.CloudRedisClient()
756+ >>>
757+ >>> name = client.instance_path('[PROJECT]', '[LOCATION]', '[INSTANCE]')
758+ >>>
759+ >>> # TODO: Initialize `output_config`:
760+ >>> output_config = {}
761+ >>>
762+ >>> response = client.export_instance(name, output_config)
763+ >>>
764+ >>> def callback(operation_future):
765+ ... # Handle result.
766+ ... result = operation_future.result()
767+ >>>
768+ >>> response.add_done_callback(callback)
769+ >>>
770+ >>> # Handle metadata.
771+ >>> metadata = response.metadata()
772+
773+ Args:
774+ name (str): Required. Redis instance resource name using the form:
775+ ``projects/{project_id}/locations/{location_id}/instances/{instance_id}``
776+ where ``location_id`` refers to a GCP region
777+ output_config (Union[dict, ~google.cloud.redis_v1.types.OutputConfig]): Required. Specify data to be exported.
778+
779+ If a dict is provided, it must be of the same form as the protobuf
780+ message :class:`~google.cloud.redis_v1.types.OutputConfig`
781+ retry (Optional[google.api_core.retry.Retry]): A retry object used
782+ to retry requests. If ``None`` is specified, requests will not
783+ be retried.
784+ timeout (Optional[float]): The amount of time, in seconds, to wait
785+ for the request to complete. Note that if ``retry`` is
786+ specified, the timeout applies to each individual attempt.
787+ metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
788+ that is provided to the method.
789+
790+ Returns:
791+ A :class:`~google.cloud.redis_v1.types._OperationFuture` instance.
792+
793+ Raises:
794+ google.api_core.exceptions.GoogleAPICallError: If the request
795+ failed for any reason.
796+ google.api_core.exceptions.RetryError: If the request failed due
797+ to a retryable error and retry attempts failed.
798+ ValueError: If the parameters are invalid.
799+ """
800+ # Wrap the transport method to add retry and timeout logic.
801+ if "export_instance" not in self ._inner_api_calls :
802+ self ._inner_api_calls [
803+ "export_instance"
804+ ] = google .api_core .gapic_v1 .method .wrap_method (
805+ self .transport .export_instance ,
806+ default_retry = self ._method_configs ["ExportInstance" ].retry ,
807+ default_timeout = self ._method_configs ["ExportInstance" ].timeout ,
808+ client_info = self ._client_info ,
809+ )
810+
811+ request = cloud_redis_pb2 .ExportInstanceRequest (
812+ name = name , output_config = output_config
813+ )
814+ operation = self ._inner_api_calls ["export_instance" ](
815+ request , retry = retry , timeout = timeout , metadata = metadata
816+ )
817+ return google .api_core .operation .from_gapic (
818+ operation ,
819+ self .transport ._operations_client ,
820+ cloud_redis_pb2 .Instance ,
821+ metadata_type = cloud_redis_pb2 .OperationMetadata ,
822+ )
823+
824+ def failover_instance (
825+ self ,
826+ name ,
827+ data_protection_mode ,
828+ retry = google .api_core .gapic_v1 .method .DEFAULT ,
829+ timeout = google .api_core .gapic_v1 .method .DEFAULT ,
830+ metadata = None ,
831+ ):
832+ """
833+ Failover the master role to current replica node against a specific
834+ STANDARD tier redis instance.
835+
836+ Example:
837+ >>> from google.cloud import redis_v1
838+ >>> from google.cloud.redis_v1 import enums
839+ >>>
840+ >>> client = redis_v1.CloudRedisClient()
841+ >>>
842+ >>> name = client.instance_path('[PROJECT]', '[LOCATION]', '[INSTANCE]')
843+ >>>
844+ >>> # TODO: Initialize `data_protection_mode`:
845+ >>> data_protection_mode = enums.FailoverInstanceRequest.DataProtectionMode.DATA_PROTECTION_MODE_UNSPECIFIED
846+ >>>
847+ >>> response = client.failover_instance(name, data_protection_mode)
848+ >>>
849+ >>> def callback(operation_future):
850+ ... # Handle result.
851+ ... result = operation_future.result()
852+ >>>
853+ >>> response.add_done_callback(callback)
854+ >>>
855+ >>> # Handle metadata.
856+ >>> metadata = response.metadata()
857+
858+ Args:
859+ name (str): Required. Redis instance resource name using the form:
860+ ``projects/{project_id}/locations/{location_id}/instances/{instance_id}``
861+ where ``location_id`` refers to a GCP region
862+ data_protection_mode (~google.cloud.redis_v1.types.DataProtectionMode): Optional. Available data protection modes that the user can choose. If
863+ it's unspecified, data protection mode will be LIMITED\_DATA\_LOSS by
864+ default.
865+ retry (Optional[google.api_core.retry.Retry]): A retry object used
866+ to retry requests. If ``None`` is specified, requests will not
867+ be retried.
868+ timeout (Optional[float]): The amount of time, in seconds, to wait
869+ for the request to complete. Note that if ``retry`` is
870+ specified, the timeout applies to each individual attempt.
871+ metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
872+ that is provided to the method.
873+
874+ Returns:
875+ A :class:`~google.cloud.redis_v1.types._OperationFuture` instance.
876+
877+ Raises:
878+ google.api_core.exceptions.GoogleAPICallError: If the request
879+ failed for any reason.
880+ google.api_core.exceptions.RetryError: If the request failed due
881+ to a retryable error and retry attempts failed.
882+ ValueError: If the parameters are invalid.
883+ """
884+ # Wrap the transport method to add retry and timeout logic.
885+ if "failover_instance" not in self ._inner_api_calls :
886+ self ._inner_api_calls [
887+ "failover_instance"
888+ ] = google .api_core .gapic_v1 .method .wrap_method (
889+ self .transport .failover_instance ,
890+ default_retry = self ._method_configs ["FailoverInstance" ].retry ,
891+ default_timeout = self ._method_configs ["FailoverInstance" ].timeout ,
892+ client_info = self ._client_info ,
893+ )
894+
895+ request = cloud_redis_pb2 .FailoverInstanceRequest (
896+ name = name , data_protection_mode = data_protection_mode
897+ )
898+ operation = self ._inner_api_calls ["failover_instance" ](
899+ request , retry = retry , timeout = timeout , metadata = metadata
900+ )
901+ return google .api_core .operation .from_gapic (
902+ operation ,
903+ self .transport ._operations_client ,
904+ cloud_redis_pb2 .Instance ,
905+ metadata_type = cloud_redis_pb2 .OperationMetadata ,
906+ )
0 commit comments