Skip to content

feat(jobs): add Jobs.stop() method [PLT-100574]#337

Open
ninja-shreyash wants to merge 1 commit intomainfrom
feat/sdk-plt-100574
Open

feat(jobs): add Jobs.stop() method [PLT-100574]#337
ninja-shreyash wants to merge 1 commit intomainfrom
feat/sdk-plt-100574

Conversation

@ninja-shreyash
Copy link
Copy Markdown
Contributor

Method Added

Layer Method Signature
Service jobs.stop() stop(jobKeys: string[], folderId: number, options?: JobStopOptions): Promise<OperationResponse<JobStopData>>

Endpoint Called

Method HTTP Endpoint OAuth Scope
stop() (resolve) GET /orchestrator_/odata/Jobs OR.Jobs
stop() (action) POST /orchestrator_/odata/Jobs/UiPath.Server.Configuration.OData.StopJobs OR.Jobs
  • Extends FolderScopedService — sets X-UIPATH-OrganizationUnitId header
  • Composite method: resolves UUID keys → integer IDs, then calls StopJobs OData action
  • Keys are chunked in batches of 50 to avoid URL length limits
  • Supports SoftStop (graceful) and Kill (forceful) strategies via existing StopStrategy enum

Example Usage

import { UiPath } from '@uipath/uipath-typescript/core';
import { Jobs } from '@uipath/uipath-typescript/jobs';

const sdk = new UiPath(config);
await sdk.initialize();
const jobs = new Jobs(sdk);

// Stop a single job with default soft stop
const result = await jobs.stop(
  ['c80c3b30-f010-4eb8-82d4-b67bc615e137'],
  123
);

// Force-kill multiple jobs
const killResult = await jobs.stop(
  ['c80c3b30-f010-4eb8-82d4-b67bc615e137', '24ef1040-454d-4184-b994-c641ee32318d'],
  123,
  { strategy: StopStrategy.Kill }
);

API Response vs SDK Response

Composition flow

1. GET /odata/Jobs?$filter=Key in ('key1','key2',...)&$select=Id,Key
   → Resolves UUID keys to integer IDs (chunked in batches of 50)
2. POST /odata/Jobs/UiPath.Server.Configuration.OData.StopJobs
   Body: { jobIds: [int,...], strategy: "SoftStop" | "Kill" }
   → Returns empty 200 on success
Final: OperationResponse<JobStopData> = { success: true, data: { jobIds: [int,...] } }

Additional fix

Added responseType: 'text' handling to api-client.ts for endpoints returning empty HTTP 200 bodies (StopJobs returns 200 with no body, not 204).

Files

Area Files
Endpoint src/utils/constants/endpoints/orchestrator.ts
Types src/models/orchestrator/jobs.types.ts
Models src/models/orchestrator/jobs.models.ts
Service src/services/orchestrator/jobs/jobs.ts
Core src/core/http/api-client.ts (text responseType support)
Unit tests tests/unit/services/orchestrator/jobs.test.ts (12 tests)
Integration tests tests/integration/shared/orchestrator/jobs.integration.test.ts (5 tests)
Test utils tests/utils/constants/jobs.ts
Docs docs/oauth-scopes.md

Refs PLT-100574

🤖 Auto-generated using onboarding skills

Add stop method to the Jobs service that stops one or more jobs by their
UUID keys. Resolves keys to integer IDs in batches of 50, then calls the
StopJobs OData action. Supports SoftStop and Kill strategies.

Also adds text responseType handling to api-client for endpoints returning
empty 200 responses.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ninja-shreyash ninja-shreyash requested a review from a team March 30, 2026 12:24
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant