# `GcpCompute.Operation`
[🔗](https://github.com/nyo16/gcp_compute/blob/v0.3.0/lib/gcp_compute/operation.ex#L1)

A Compute Engine [Operation](https://cloud.google.com/compute/docs/reference/rest/v1/zoneOperations).

Every mutating call (`insert`, `delete`, `start`, `stop`, …) is asynchronous
and returns an `Operation`. Wait for it with `GcpCompute.Operations.wait/2` or
`GcpCompute.Operations.poll_until_done/3`.

# `scope`

```elixir
@type scope() :: {:zone, String.t()} | {:region, String.t()} | :global
```

# `status`

```elixir
@type status() :: :pending | :running | :done | String.t()
```

# `t`

```elixir
@type t() :: %GcpCompute.Operation{
  end_time: DateTime.t() | nil,
  error: map() | nil,
  http_error_message: String.t() | nil,
  http_error_status_code: integer() | nil,
  insert_time: DateTime.t() | nil,
  name: String.t() | nil,
  operation_type: String.t() | nil,
  progress: integer() | nil,
  raw: map(),
  region: String.t() | nil,
  start_time: DateTime.t() | nil,
  status: status() | nil,
  status_message: String.t() | nil,
  target_id: String.t() | nil,
  target_link: String.t() | nil,
  zone: String.t() | nil
}
```

# `done?`

```elixir
@spec done?(t()) :: boolean()
```

True once the operation has reached the `:done` status.

# `error?`

```elixir
@spec error?(t()) :: boolean()
```

True if the (done) operation carries an error payload.

# `from_json`

```elixir
@spec from_json(map()) :: t()
```

Parse a decoded JSON operation map into a struct.

# `scope`

```elixir
@spec scope(t()) :: scope()
```

Where the operation lives — `{:zone, z}`, `{:region, r}`, or `:global`.

# `to_error`

```elixir
@spec to_error(t()) :: GcpCompute.Error.t()
```

Convert a failed operation into a `GcpCompute.Error`.

Shape-matched rather than `get_in/2`-based: `error?/1` is true for *any*
non-nil `:error`, so a binary `error`, or an `"errors"` value that is a map
instead of a list, used to raise `ArgumentError` on the failure path — the
worst place for a second failure.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
