# Cloud Spanner API - Class Google::Cloud::Spanner::Instance::Job (v2.36.0)

2.36.0 (latest) 2.35.0 2.34.0 2.33.0 2.32.0 2.31.0 2.30.0 2.29.0 2.28.0 2.27.0 2.26.0 2.25.0 2.24.0 2.23.0 2.22.0 2.21.0 2.20.0 2.19.1 2.18.1 2.17.0 2.16.1 2.15.0 2.14.0 2.13.0 2.12.1 2.11.0 Reference documentation and code samples for the Cloud Spanner API class Google::Cloud::Spanner::Instance::Job.

## Job

A resource representing the long-running, asynchronous processing of
an instance create or update operation. The job can be refreshed to
retrieve the instance object once the operation has been completed.

See [Project#create_instance](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Project#Google__Cloud__Spanner__Project_create_instance_instance_ "Google::Cloud::Spanner::Project#create_instance (method)") and [#update](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Instance#Google__Cloud__Spanner__Instance_update_instance_ "Google::Cloud::Spanner::Instance#update (method)").

## Inherits

- Object

## Example

```ruby
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

job = spanner.create_instance "my-new-instance",
                              name: "My New Instance",
                              config: "regional-us-central1",
                              nodes: 5,
                              labels: { production: :env }

job.done? #=> false
job.reload! # API call
job.done? #=> true

if job.error?
  status = job.error
else
  instance = job.instance
end
```

## Methods

### #done?

    def done?() -> boolean

Checks if the processing of the instance operation is complete.
**Returns**

- (boolean) --- `true` when complete, `false` otherwise.
**Example**

```ruby
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

job = spanner.create_instance "my-new-instance",
                              name: "My New Instance",
                              config: "regional-us-central1",
                              nodes: 5,
                              labels: { production: :env }

job.done? #=> false
```

### #error

    def error() -> Google::Cloud::Spanner::Status, nil

The status if the operation associated with this job produced an
error.
**Returns**

- ([Google::Cloud::Spanner::Status](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Status), nil) --- A status object with the status code and message, or `nil` if no error occurred.
**Example**

```ruby
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

job = spanner.create_instance "my-new-instance",
                              name: "My New Instance",
                              config: "regional-us-central1",
                              nodes: 5,
                              labels: { production: :env }

job.error? # true

error = job.error
```

### #error?

    def error?() -> boolean

Checks if the processing of the instance operation has errored.
**Returns**

- (boolean) --- `true` when errored, `false` otherwise.
**Example**

```ruby
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

job = spanner.create_instance "my-new-instance",
                              name: "My New Instance",
                              config: "regional-us-central1",
                              nodes: 5,
                              labels: { production: :env }

job.error? #=> false
```

### #instance

    def instance() -> Google::Cloud::Spanner::Instance, nil

The instance that is the object of the operation.
**Returns**

- ([Google::Cloud::Spanner::Instance](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Instance), nil) --- The instance, or `nil` if the operation is not complete.
**Example**

```ruby
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

job = spanner.create_instance "my-new-instance",
                              name: "My New Instance",
                              config: "regional-us-central1",
                              nodes: 5,
                              labels: { production: :env }

job.done? #=> false
job.reload!
job.done? #=> true
instance = job.instance
```

### #refresh!

    def refresh!() -> Google::Cloud::Spanner::Instance::Job

**Alias Of** : [#reload!](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Instance-Job#Google__Cloud__Spanner__Instance__Job_reload!_instance_) Reloads the job with current data from the long-running,
asynchronous processing of an instance operation.
**Returns**

- ([Google::Cloud::Spanner::Instance::Job](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Instance-Job)) --- The same job instance.
**Example**

```ruby
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

job = spanner.create_instance "my-new-instance",
                              name: "My New Instance",
                              config: "regional-us-central1",
                              nodes: 5,
                              labels: { production: :env }

job.done? #=> false
job.reload! # API call
job.done? #=> true
```

### #reload!

    def reload!() -> Google::Cloud::Spanner::Instance::Job

**Aliases**

- [#refresh!](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Instance-Job#Google__Cloud__Spanner__Instance__Job_refresh!_instance_)
Reloads the job with current data from the long-running,
asynchronous processing of an instance operation.
**Returns**

- ([Google::Cloud::Spanner::Instance::Job](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Instance-Job)) --- The same job instance.
**Example**

```ruby
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

job = spanner.create_instance "my-new-instance",
                              name: "My New Instance",
                              config: "regional-us-central1",
                              nodes: 5,
                              labels: { production: :env }

job.done? #=> false
job.reload! # API call
job.done? #=> true
```

### #wait_until_done!

    def wait_until_done!()

Reloads the job until the operation is complete. The delay between
reloads will incrementally increase.
**Example**

```ruby
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

job = spanner.create_instance "my-new-instance",
                              name: "My New Instance",
                              config: "regional-us-central1",
                              nodes: 5,
                              labels: { production: :env }

job.done? #=> false
job.wait_until_done!
job.done? #=> true
```