@nebius/js-sdk - v0.2.78
    Preparing search index...

    Class Operation<TReq>

    Polls a long-running operation and exposes its current state.

    Mutating service methods often return an operation instead of the final resource. Operation.wait resolves on success and rejects failed operations with OperationError. The operation retains its final status.

    const op = await service.create(req).result;
    await op.wait();
    console.log('resource ID', op.resourceId());

    Type Parameters

    • TReq

    Indexable

    • [key: symbol]: () => unknown

      Polls a long-running operation and exposes its current state.

      Mutating service methods often return an operation instead of the final resource. Operation.wait resolves on success and rejects failed operations with OperationError. The operation retains its final status.

        • (): unknown
        • Returns a JSON-safe value for logs.

          Returns unknown

    Index
    $type: "nebius.sdk.Operation" = 'nebius.sdk.Operation'

    Contains the fully qualified runtime type name.

    innerType: string

    Contains the protobuf type name of the wrapped operation.

    • Returns the ID of the user or service account that created the operation.

      Returns string

    • Returns the progress tracker.

      Returns undefined when the service does not provide progress.

      Returns OperationProgressTracker | undefined

      const tracker = op.progressTracker();
      if (tracker) {
      console.log(tracker.description());
      const steps = tracker.steps();
      if (steps.length > 0) console.log('first step', steps[0].description());
      }
    • Copies the saved request headers.

      Returns Record<string, string[]>

    • Returns the affected resource ID.

      A service can return an empty string before it assigns the resource ID.

      Returns string

    • Checks whether the operation finished successfully.

      Returns false while the operation is still running.

      Returns boolean

    • Gets the latest operation state from the operation service.

      The method refreshes the wrapped state in place. Request errors reject the returned promise.

      Parameters

      • Optionalmetadata: Metadata
      • Optionaloptions: Partial<CallOptions> & RetryOptions

      Returns Promise<void>

      await op.update();
      if (op.done()) console.log('finished', op.status());
    • Polls the operation until the service returns a final status.

      The method updates this object in place. It continues after a polling call reaches its per-attempt deadline, because the remote operation can still be running. Consecutive retriable polling errors use exponential backoff with jitter. It rethrows non-retriable polling errors and rejects failed operations. A resolved promise means that the operation succeeded. The caller deadline, timeoutMs, or AbortSignal stops local waiting without canceling the remote operation.

      Parameters

      • intervalSec: number = DEFAULT_POLL_INTERVAL_SEC

        Sets the poll interval in seconds. Non-positive values use the default of 1.

      • Optionalmetadata: Metadata

        Sends metadata with every polling request.

      • Optionaloptions: OperationWaitOptions & Partial<CallOptions>

        Sets gRPC deadlines, request retries, and poll-error backoff.

      Returns Promise<void>

      await op.wait(1); // poll once per second