Ejemplo n.º 1
0
    def restore(self, table_id, instance_id=None):
        """Creates a new Table by restoring from this Backup. The new Table
        can be created in the same Instance as the Instance containing the
        Backup, or another Instance whose ID can be specified in the arguments.
        The returned Table ``long-running operation`` can be used to track the
        progress of the operation and to cancel it. The ``response`` type is
        ``Table``, if successful.

        :type table_id: str
        :param table_id: The ID of the Table to create and restore to.
                         This Table must not already exist.

        :type instance_id: str
        :param instance_id: (Optional) The ID of the Instance to restore the
                            backup into, if different from the current one.

        :rtype: :class:`~google.cloud.bigtable_admin_v2.types._OperationFuture`
        :returns: A future to be used to poll the status of the 'restore'
                  request.

        :raises: google.api_core.exceptions.AlreadyExists: If the table
                 already exists.
        :raises: google.api_core.exceptions.GoogleAPICallError: If the request
                 failed for any reason.
        :raises: google.api_core.exceptions.RetryError: If the request failed
                 due to a retryable error and retry attempts failed.
        :raises: ValueError: If the parameters are invalid.
        """
        api = self._instance._client.table_admin_client
        if instance_id:
            parent = BigtableTableAdminClient.instance_path(
                project=self._instance._client.project,
                instance=instance_id,
            )
        else:
            parent = self._instance.name

        return api.restore_table(request={
            "parent": parent,
            "table_id": table_id,
            "backup": self.name
        })
Ejemplo n.º 2
0
    def source_table(self):
        """The full name of the Table from which this Backup is created.

        .. note::
          This property will return None if ``table_id`` is not set.

        The table name is of the form

            ``"projects/../instances/../tables/{source_table}"``

        :rtype: str
        :returns: The Table name.
        """
        if not self._source_table and self.table_id:
            self._source_table = BigtableTableAdminClient.table_path(
                project=self._instance._client.project,
                instance=self._instance.instance_id,
                table=self.table_id,
            )
        return self._source_table
Ejemplo n.º 3
0
    def parent(self):
        """Name of the parent cluster used in requests.

        .. note::
          This property will return None if ``cluster`` is not set.

        The parent name is of the form

            ``"projects/{project}/instances/{instance_id}/clusters/{cluster}"``

        :rtype: str
        :returns: A full path to the parent cluster.
        """
        if not self._parent and self._cluster:
            self._parent = BigtableTableAdminClient.cluster_path(
                project=self._instance._client.project,
                instance=self._instance.instance_id,
                cluster=self._cluster,
            )
        return self._parent
Ejemplo n.º 4
0
    def name(self):
        """Backup name used in requests.

        The Backup name is of the form

            ``"projects/../instances/../clusters/../backups/{backup_id}"``

        :rtype: str
        :returns: The Backup name.

        :raises: ValueError: If the 'cluster' has not been set.
        """
        if not self._cluster:
            raise ValueError('"cluster" parameter must be set')

        return BigtableTableAdminClient.backup_path(
            project=self._instance._client.project,
            instance=self._instance.instance_id,
            cluster=self._cluster,
            backup=self.backup_id,
        )