@nebius/js-sdk - v0.2.54
    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 completes for both successful and failed operations. After it completes, inspect Operation.status or Operation.successful. It rejects only when polling cannot continue.

    const op = await service.create(req).result;
    await op.wait();
    if (!op.successful()) {
    throw new Error(`operation failed: ${op.status()?.message}`);
    }
    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 completes for both successful and failed operations. After it completes, inspect Operation.status or Operation.successful. It rejects only when polling cannot continue.

        • (): 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());
      }
    • 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 replaces the wrapped state in place. It does nothing when the operation has no ID. 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 deadline, because the remote operation can still be running. Consecutive retriable polling errors use exponential backoff with jitter. It rethrows non-retriable polling errors. A resolved promise does not mean that the operation succeeded; call successful or inspect status. The method returns immediately when the operation ID is empty.

      Parameters

      • intervalSec: number = DEFAULT_POLL_INTERVAL_SEC

        Sets the poll interval in seconds. The default is 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