Liking cljdoc? Tell your friends :D

clj-oci.compute

OCI Compute API wrapper — Instance CRUD + lifecycle.

Provides operations for the canonical Instance resource on ComputeClient:

  • list-instances — paginated listing with filters
  • get-instance — fetch a single instance
  • launch-instance — create
  • update-instance — update mutable fields
  • terminate-instance — delete
  • instance-action — power state (START/STOP/RESET/SOFTSTOP/...)
  • change-instance-compartment— move between compartments

Plus helpers for the most common polymorphic launch-input slot:

  • image-source-details — InstanceSourceViaImageDetails
  • boot-volume-source-details — InstanceSourceViaBootVolumeDetails

list-instances results are cached via service.memo; mutations bypass the cache and invalidate the compute/list-instances prefix on success.

Note: oci/http-request currently discards response headers, so this namespace cannot return etag for optimistic concurrency or opc-work-request-id for async tracking. Wrappers accept :if-match outbound but cannot surface header values inbound.

OCI Compute API wrapper — Instance CRUD + lifecycle.

Provides operations for the canonical `Instance` resource on `ComputeClient`:
- `list-instances`             — paginated listing with filters
- `get-instance`               — fetch a single instance
- `launch-instance`            — create
- `update-instance`            — update mutable fields
- `terminate-instance`         — delete
- `instance-action`            — power state (START/STOP/RESET/SOFTSTOP/...)
- `change-instance-compartment`— move between compartments

Plus helpers for the most common polymorphic launch-input slot:
- `image-source-details`       — InstanceSourceViaImageDetails
- `boot-volume-source-details` — InstanceSourceViaBootVolumeDetails

`list-instances` results are cached via `service.memo`; mutations bypass the
cache and invalidate the `compute/list-instances` prefix on success.

Note: `oci/http-request` currently discards response headers, so this
namespace cannot return `etag` for optimistic concurrency or
`opc-work-request-id` for async tracking. Wrappers accept `:if-match`
outbound but cannot surface header values inbound.
raw docstring

boot-volume-source-detailsclj

(boot-volume-source-details params)

Builds an InstanceSourceViaBootVolumeDetails for use as :source-details on launch-instance.

Required: :bootVolumeId

Builds an `InstanceSourceViaBootVolumeDetails` for use as `:source-details`
on `launch-instance`.

Required: `:bootVolumeId`
raw docstring

change-instance-compartmentclj

(change-instance-compartment instance-id target-compartment-id)
(change-instance-compartment instance-id target-compartment-id opts)

Moves an instance to a different compartment within the same tenancy.

Async (work-request); the API returns 202. Boot volumes and VNICs do NOT move with the instance — move those independently if needed.

Returns {:data ...} (response body is empty per the API spec, but the wrapper returns whatever from-java produces) or {:error ...}. Invalidates the list cache on success.

Options: :if-match — etag for optimistic concurrency :opc-retry-token — idempotency token

Moves an instance to a different compartment within the same tenancy.

Async (work-request); the API returns 202. Boot volumes and VNICs do NOT
move with the instance — move those independently if needed.

Returns `{:data ...}` (response body is empty per the API spec, but the
wrapper returns whatever `from-java` produces) or `{:error ...}`. Invalidates
the list cache on success.

Options:
  :if-match        — etag for optimistic concurrency
  :opc-retry-token — idempotency token
raw docstring

get-instanceclj

(get-instance instance-id)
(get-instance instance-id opts)

Fetches a single instance by OCID. Not memoized (lifecycle state changes too quickly for caching to be useful).

The region is resolved from the instance OCID's region segment; pass :region "us-ashburn-1" in opts to override.

Returns {:data {...}} or {:error ...} on failure.

Fetches a single instance by OCID. Not memoized (lifecycle state changes
too quickly for caching to be useful).

The region is resolved from the instance OCID's region segment; pass
`:region "us-ashburn-1"` in opts to override.

Returns `{:data {...}}` or `{:error ...}` on failure.
raw docstring

image-source-detailsclj

(image-source-details params)

Builds an InstanceSourceViaImageDetails for use as :source-details on launch-instance.

Required: :imageId Optional: :bootVolumeSizeInGBs, :bootVolumeVpusPerGB, :kmsKeyId, :instanceSourceImageFilterDetails (pre-built Java)

Builds an `InstanceSourceViaImageDetails` for use as `:source-details`
on `launch-instance`.

Required: `:imageId`
Optional: `:bootVolumeSizeInGBs`, `:bootVolumeVpusPerGB`, `:kmsKeyId`,
          `:instanceSourceImageFilterDetails` (pre-built Java)
raw docstring

instance-actionclj

(instance-action instance-id action)
(instance-action instance-id action opts)

Performs a power-state action on an instance. Synchronous — returns the updated Instance body.

action is a keyword: :start, :stop, :reset, :softstop, :softreset, :senddiagnosticinterrupt, :diagnosticreboot, :rebootmigrate. A wire-format string (e.g. "START") is also accepted.

Returns {:data {...}} or {:error ...}. Invalidates the list cache on success.

Options: :if-match — etag for optimistic concurrency :opc-retry-token — idempotency token :instance-power-action-details — pre-built InstancePowerActionDetails (e.g. for RESET-with-allowDenseRebootMigration)

Performs a power-state action on an instance. Synchronous — returns the
updated `Instance` body.

`action` is a keyword: `:start`, `:stop`, `:reset`, `:softstop`, `:softreset`,
`:senddiagnosticinterrupt`, `:diagnosticreboot`, `:rebootmigrate`. A wire-format
string (e.g. "START") is also accepted.

Returns `{:data {...}}` or `{:error ...}`. Invalidates the list cache on success.

Options:
  :if-match                       — etag for optimistic concurrency
  :opc-retry-token                — idempotency token
  :instance-power-action-details  — pre-built InstancePowerActionDetails
                                    (e.g. for RESET-with-allowDenseRebootMigration)
raw docstring

launch-instanceclj

(launch-instance details)
(launch-instance details opts)

Creates a new compute instance.

Top-level fields accept kebab-case keys; nested SDK types must be pre-built Java instances. See launch-instance-details for the full set of nested slots and their target types.

The most common polymorphic slot — :source-details — has helpers image-source-details and boot-volume-source-details.

Example:

(require '[clj-oci.compute :as compute] '[clojure.java.data.builder :as builder]) (import '[com.oracle.bmc.core.model CreateVnicDetails LaunchInstanceShapeConfigDetails])

(compute/launch-instance {:availability-domain "Uocm:PHX-AD-1" :compartment-id "ocid1.compartment..." :display-name "my-vm" :shape "VM.Standard.E4.Flex" :shape-config (builder/to-java LaunchInstanceShapeConfigDetails {:ocpus 4.0 :memoryInGBs 16.0}) :source-details (compute/image-source-details {:imageId "ocid1.image..."}) :create-vnic-details (builder/to-java CreateVnicDetails {:subnetId "ocid1.subnet..." :assignPublicIp false}) :metadata {"ssh_authorized_keys" "ssh-rsa AAAA..."}})

Returns {:data {...}} (the new Instance) or {:error ...}. Invalidates the list cache on success.

Region resolution: when :region is absent from opts, derives the region from details' :availability-domain (e.g. "FDlC:PHX-AD-1" → us-phoenix-1 via Region/fromRegionCode). Falls back to the singleton's default region if no AD is provided or the AD is unrecognized.

Options: :region — region-id ("us-ashburn-1") or 3-letter code ("iad") :opc-retry-token — idempotency token (max 64 chars, expires after 24h)

Creates a new compute instance.

Top-level fields accept kebab-case keys; nested SDK types must be pre-built
Java instances. See `launch-instance-details` for the full set of nested
slots and their target types.

The most common polymorphic slot — `:source-details` — has helpers
`image-source-details` and `boot-volume-source-details`.

Example:

  (require '[clj-oci.compute :as compute]
           '[clojure.java.data.builder :as builder])
  (import '[com.oracle.bmc.core.model
            CreateVnicDetails LaunchInstanceShapeConfigDetails])

  (compute/launch-instance
    {:availability-domain  "Uocm:PHX-AD-1"
     :compartment-id       "ocid1.compartment..."
     :display-name         "my-vm"
     :shape                "VM.Standard.E4.Flex"
     :shape-config         (builder/to-java LaunchInstanceShapeConfigDetails
                                            {:ocpus 4.0 :memoryInGBs 16.0})
     :source-details       (compute/image-source-details {:imageId "ocid1.image..."})
     :create-vnic-details  (builder/to-java CreateVnicDetails
                                            {:subnetId "ocid1.subnet..."
                                             :assignPublicIp false})
     :metadata             {"ssh_authorized_keys" "ssh-rsa AAAA..."}})

Returns `{:data {...}}` (the new `Instance`) or `{:error ...}`. Invalidates
the list cache on success.

Region resolution: when `:region` is absent from opts, derives the region
from `details`' `:availability-domain` (e.g. "FDlC:PHX-AD-1" → us-phoenix-1
via `Region/fromRegionCode`). Falls back to the singleton's default region
if no AD is provided or the AD is unrecognized.

Options:
  :region          — region-id ("us-ashburn-1") or 3-letter code ("iad")
  :opc-retry-token — idempotency token (max 64 chars, expires after 24h)
raw docstring

list-instancesclj

(list-instances compartment-id)
(list-instances compartment-id opts)

Fetches all compute instances in compartment-id, paginating automatically.

Results are cached in Datahike; subsequent calls with the same parameter set return cached data unless :refresh? is set.

Returns {:data {:items [instance-maps...]}} or {:error ...} on failure. Each instance map has camelCase keyword keys as produced by from-java, e.g. :displayName, :shapeConfig, :definedTags, :lifecycleState, :id.

Options (all keys optional unless noted): :limit — page size (default 100) :availability-domain — string e.g. "Uocm:PHX-AD-1" :capacity-reservation-id — OCID :compute-cluster-id — OCID :display-name — exact match (case-sensitive) :lifecycle-state — keyword (:running :stopped …) or Java constant :sort-by — :time-created or :display-name :sort-order — :asc or :desc :region — region-id (e.g. "us-ashburn-1") or 3-letter code ("iad"); defaults to the singleton's region. Required to list instances in a non-default region — compartment OCIDs do not carry a region segment. :refresh? — force re-fetch from OCI (default false) :max-age-seconds — re-fetch if cached entry is older (default nil)

Fetches all compute instances in `compartment-id`, paginating automatically.

Results are cached in Datahike; subsequent calls with the same parameter
set return cached data unless `:refresh?` is set.

Returns `{:data {:items [instance-maps...]}}` or `{:error ...}` on failure.
Each instance map has camelCase keyword keys as produced by `from-java`,
e.g. `:displayName`, `:shapeConfig`, `:definedTags`, `:lifecycleState`, `:id`.

Options (all keys optional unless noted):
  :limit                   — page size (default 100)
  :availability-domain     — string e.g. "Uocm:PHX-AD-1"
  :capacity-reservation-id — OCID
  :compute-cluster-id      — OCID
  :display-name            — exact match (case-sensitive)
  :lifecycle-state         — keyword (:running :stopped …) or Java constant
  :sort-by                 — :time-created or :display-name
  :sort-order              — :asc or :desc
  :region                  — region-id (e.g. "us-ashburn-1") or 3-letter
                             code ("iad"); defaults to the singleton's
                             region. Required to list instances in a
                             non-default region — compartment OCIDs do not
                             carry a region segment.
  :refresh?                — force re-fetch from OCI (default false)
  :max-age-seconds         — re-fetch if cached entry is older (default nil)
raw docstring

terminate-instanceclj

(terminate-instance instance-id)
(terminate-instance instance-id opts)

Permanently terminates an instance.

By default the boot volume is deleted and data volumes created at launch are preserved (matches the OCI API defaults).

Returns {:data nil} on success (the API returns 204 No Content) or {:error ...} on failure. On success, invalidates the compute/list-instances cache.

Options: :preserve-boot-volume — keep boot volume (default false) :preserve-data-volumes-created-at-launch — keep data volumes (default true) :if-match — etag for optimistic concurrency

Permanently terminates an instance.

By default the boot volume is deleted and data volumes created at launch
are preserved (matches the OCI API defaults).

Returns `{:data nil}` on success (the API returns 204 No Content) or
`{:error ...}` on failure. On success, invalidates the `compute/list-instances`
cache.

Options:
  :preserve-boot-volume                    — keep boot volume (default false)
  :preserve-data-volumes-created-at-launch — keep data volumes (default true)
  :if-match                                — etag for optimistic concurrency
raw docstring

update-instanceclj

(update-instance instance-id details)
(update-instance instance-id details opts)

Updates mutable fields on an instance.

Top-level fields accept kebab-case keys and are translated to the SDK's camelCase setters. Nested SDK types — :agent-config, :availability-config, :shape-config, :instance-options, :launch-options, :platform-config, :source-details, :licensing-configs — must be pre-built Java instances.

Example:

(require '[clojure.java.data.builder :as builder]) (import '[com.oracle.bmc.core.model UpdateInstanceShapeConfigDetails])

(update-instance "ocid1.instance..." {:display-name "renamed-vm" :shape-config (builder/to-java UpdateInstanceShapeConfigDetails {:ocpus 8.0 :memoryInGBs 32.0})} {:if-match "etag-from-get-instance"})

Returns {:data {...}} (updated Instance) or {:error ...}. Invalidates the list cache on success.

Options: :if-match — etag for optimistic concurrency :opc-retry-token — idempotency token

Updates mutable fields on an instance.

Top-level fields accept kebab-case keys and are translated to the SDK's
camelCase setters. Nested SDK types — `:agent-config`, `:availability-config`,
`:shape-config`, `:instance-options`, `:launch-options`, `:platform-config`,
`:source-details`, `:licensing-configs` — must be pre-built Java instances.

Example:

  (require '[clojure.java.data.builder :as builder])
  (import '[com.oracle.bmc.core.model UpdateInstanceShapeConfigDetails])

  (update-instance
    "ocid1.instance..."
    {:display-name "renamed-vm"
     :shape-config (builder/to-java UpdateInstanceShapeConfigDetails
                                    {:ocpus 8.0 :memoryInGBs 32.0})}
    {:if-match "etag-from-get-instance"})

Returns `{:data {...}}` (updated `Instance`) or `{:error ...}`. Invalidates
the list cache on success.

Options:
  :if-match        — etag for optimistic concurrency
  :opc-retry-token — idempotency token
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close