Skip to content

Commit eb62ee1

Browse files
refactor(jobs): rename getByKey to getById [PLT-100298]
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c5d9909 commit eb62ee1

File tree

6 files changed

+37
-37
lines changed

6 files changed

+37
-37
lines changed

docs/oauth-scopes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This page lists the specific OAuth scopes required in external app for each SDK
1414
| Method | OAuth Scope |
1515
|--------|-------------|
1616
| `getAll()` | `OR.Jobs` or `OR.Jobs.Read` |
17-
| `getByKey()` | `OR.Jobs` or `OR.Jobs.Read` |
17+
| `getById()` | `OR.Jobs` or `OR.Jobs.Read` |
1818
| `getOutput()` | `OR.Jobs` or `OR.Jobs.Read` |
1919

2020
## Attachments

src/models/orchestrator/jobs.models.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { JobGetAllOptions, JobGetByKeyOptions, RawJobGetResponse } from './jobs.types';
1+
import { JobGetAllOptions, JobGetByIdOptions, RawJobGetResponse } from './jobs.types';
22
import { PaginatedResponse, NonPaginatedResponse, HasPaginationOptions } from '../../utils/pagination';
33

44
// Combined type for job data with methods
@@ -81,20 +81,20 @@ export interface JobServiceModel {
8181
* @example
8282
* ```typescript
8383
* // Get a job by key
84-
* const job = await jobs.getByKey(<jobKey>, <folderId>);
84+
* const job = await jobs.getById(<jobKey>, <folderId>);
8585
* console.log(job.state, job.processName);
8686
* ```
8787
*
8888
* @example
8989
* ```typescript
9090
* // With expanded related entities
91-
* const job = await jobs.getByKey(<jobKey>, <folderId>, {
91+
* const job = await jobs.getById(<jobKey>, <folderId>, {
9292
* expand: 'Robot,Machine,Release'
9393
* });
9494
* console.log(job.robot?.name, job.machine?.name);
9595
* ```
9696
*/
97-
getByKey(jobKey: string, folderId: number, options?: JobGetByKeyOptions): Promise<JobGetResponse>;
97+
getById(jobKey: string, folderId: number, options?: JobGetByIdOptions): Promise<JobGetResponse>;
9898

9999
/**
100100
* Gets the output of a completed job.

src/models/orchestrator/jobs.types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export type JobGetAllOptions = RequestOptions & PaginationOptions & {
167167
}
168168

169169
/**
170-
* Options for getting a job by key
170+
* Options for getting a job by ID
171171
*/
172-
export interface JobGetByKeyOptions extends BaseOptions {}
172+
export interface JobGetByIdOptions extends BaseOptions {}
173173

src/services/orchestrator/jobs/jobs.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { FolderScopedService } from '../../folder-scoped';
2-
import { RawJobGetResponse, JobGetAllOptions, JobGetByKeyOptions } from '../../../models/orchestrator/jobs.types';
2+
import { RawJobGetResponse, JobGetAllOptions, JobGetByIdOptions } from '../../../models/orchestrator/jobs.types';
33
import { JobServiceModel, JobGetResponse, createJobWithMethods } from '../../../models/orchestrator/jobs.models';
44
import { addPrefixToKeys, pascalToCamelCaseKeys, transformData } from '../../../utils/transform';
55
import { JOB_ENDPOINTS } from '../../../utils/constants/endpoints';
@@ -117,24 +117,24 @@ export class JobService extends FolderScopedService implements JobServiceModel {
117117
*
118118
* @example
119119
* ```typescript
120-
* // Get a job by key
121-
* const job = await jobs.getByKey(<jobKey>, <folderId>);
120+
* // Get a job by ID
121+
* const job = await jobs.getById(<jobKey>, <folderId>);
122122
* console.log(job.state, job.processName);
123123
* ```
124124
*
125125
* @example
126126
* ```typescript
127127
* // With expanded related entities
128-
* const job = await jobs.getByKey(<jobKey>, <folderId>, {
128+
* const job = await jobs.getById(<jobKey>, <folderId>, {
129129
* expand: 'Robot,Machine,Release'
130130
* });
131131
* console.log(job.robot?.name, job.machine?.name);
132132
* ```
133133
*/
134-
@track('Jobs.GetByKey')
135-
async getByKey(jobKey: string, folderId: number, options: JobGetByKeyOptions = {}): Promise<JobGetResponse> {
134+
@track('Jobs.GetById')
135+
async getById(jobKey: string, folderId: number, options: JobGetByIdOptions = {}): Promise<JobGetResponse> {
136136
if (!jobKey) {
137-
throw new ValidationError({ message: 'jobKey is required for getByKey' });
137+
throw new ValidationError({ message: 'jobKey is required for getById' });
138138
}
139139

140140
const headers = createHeaders({ [FOLDER_ID]: folderId });
@@ -191,7 +191,7 @@ export class JobService extends FolderScopedService implements JobServiceModel {
191191
throw new ValidationError({ message: 'jobKey is required for getOutput' });
192192
}
193193

194-
const job = await this.getByKey(jobKey, folderId, { select: 'OutputArguments,OutputFile' });
194+
const job = await this.getById(jobKey, folderId, { select: 'OutputArguments,OutputFile' });
195195

196196
if (job.outputArguments) {
197197
try {

tests/integration/shared/orchestrator/jobs.integration.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ describe.each(modes)('Orchestrator Jobs - Integration Tests [%s]', (mode) => {
6262
});
6363
});
6464

65-
describe('getByKey', () => {
65+
describe('getById', () => {
6666
it('should retrieve a job by key', async () => {
6767
const { jobs, folderId } = getJobsService();
6868

6969
if (!folderId) {
70-
throw new Error('INTEGRATION_TEST_FOLDER_ID is required for getByKey tests.');
70+
throw new Error('INTEGRATION_TEST_FOLDER_ID is required for getById tests.');
7171
}
7272

7373
// First get a job key from getAll
@@ -77,11 +77,11 @@ describe.each(modes)('Orchestrator Jobs - Integration Tests [%s]', (mode) => {
7777
});
7878

7979
if (allJobs.items.length === 0) {
80-
throw new Error('No jobs available to test getByKey.');
80+
throw new Error('No jobs available to test getById.');
8181
}
8282

8383
const jobKey = allJobs.items[0].key;
84-
const job = await jobs.getByKey(jobKey, folderId);
84+
const job = await jobs.getById(jobKey, folderId);
8585

8686
expect(job).toBeDefined();
8787
expect(job.id).toBeDefined();
@@ -94,7 +94,7 @@ describe.each(modes)('Orchestrator Jobs - Integration Tests [%s]', (mode) => {
9494
const { jobs, folderId } = getJobsService();
9595

9696
if (!folderId) {
97-
throw new Error('INTEGRATION_TEST_FOLDER_ID is required for getByKey tests.');
97+
throw new Error('INTEGRATION_TEST_FOLDER_ID is required for getById tests.');
9898
}
9999

100100
const allJobs = await jobs.getAll({
@@ -103,11 +103,11 @@ describe.each(modes)('Orchestrator Jobs - Integration Tests [%s]', (mode) => {
103103
});
104104

105105
if (allJobs.items.length === 0) {
106-
throw new Error('No jobs available to test getByKey with expand.');
106+
throw new Error('No jobs available to test getById with expand.');
107107
}
108108

109109
const jobKey = allJobs.items[0].key;
110-
const job = await jobs.getByKey(jobKey, folderId, {
110+
const job = await jobs.getById(jobKey, folderId, {
111111
expand: 'Robot,Machine,Release',
112112
});
113113

@@ -119,7 +119,7 @@ describe.each(modes)('Orchestrator Jobs - Integration Tests [%s]', (mode) => {
119119
const { jobs, folderId } = getJobsService();
120120

121121
if (!folderId) {
122-
throw new Error('INTEGRATION_TEST_FOLDER_ID is required for getByKey tests.');
122+
throw new Error('INTEGRATION_TEST_FOLDER_ID is required for getById tests.');
123123
}
124124

125125
const allJobs = await jobs.getAll({
@@ -128,11 +128,11 @@ describe.each(modes)('Orchestrator Jobs - Integration Tests [%s]', (mode) => {
128128
});
129129

130130
if (allJobs.items.length === 0) {
131-
throw new Error('No jobs available to test getByKey bound methods.');
131+
throw new Error('No jobs available to test getById bound methods.');
132132
}
133133

134134
const jobKey = allJobs.items[0].key;
135-
const job = await jobs.getByKey(jobKey, folderId);
135+
const job = await jobs.getById(jobKey, folderId);
136136

137137
expect(job.getOutput).toBeDefined();
138138
expect(typeof job.getOutput).toBe('function');
@@ -142,7 +142,7 @@ describe.each(modes)('Orchestrator Jobs - Integration Tests [%s]', (mode) => {
142142
const { jobs, folderId } = getJobsService();
143143

144144
if (!folderId) {
145-
throw new Error('INTEGRATION_TEST_FOLDER_ID is required for getByKey transform tests.');
145+
throw new Error('INTEGRATION_TEST_FOLDER_ID is required for getById transform tests.');
146146
}
147147

148148
const allJobs = await jobs.getAll({
@@ -155,7 +155,7 @@ describe.each(modes)('Orchestrator Jobs - Integration Tests [%s]', (mode) => {
155155
}
156156

157157
const jobKey = allJobs.items[0].key;
158-
const job = await jobs.getByKey(jobKey, folderId);
158+
const job = await jobs.getById(jobKey, folderId);
159159

160160
// Verify transformed camelCase fields exist
161161
expect(job.createdTime).toBeDefined();

tests/unit/services/orchestrator/jobs.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { createServiceTestDependencies, createMockApiClient } from '../../../uti
1111
import { createMockError } from '../../../utils/mocks/core';
1212
import {
1313
JobGetAllOptions,
14-
JobGetByKeyOptions,
14+
JobGetByIdOptions,
1515
} from '../../../../src/models/orchestrator/jobs.types';
1616
import { JobGetResponse } from '../../../../src/models/orchestrator/jobs.models';
1717
import { PaginatedResponse } from '../../../../src/utils/pagination';
@@ -176,12 +176,12 @@ describe('JobService Unit Tests', () => {
176176
});
177177
});
178178

179-
describe('getByKey', () => {
179+
describe('getById', () => {
180180
it('should return a job by key with transformed fields', async () => {
181181
const mockRawJob = createMockRawJob();
182182
mockApiClient.get.mockResolvedValueOnce(mockRawJob);
183183

184-
const result = await jobService.getByKey(JOB_TEST_CONSTANTS.JOB_KEY, TEST_CONSTANTS.FOLDER_ID);
184+
const result = await jobService.getById(JOB_TEST_CONSTANTS.JOB_KEY, TEST_CONSTANTS.FOLDER_ID);
185185

186186
expect(mockApiClient.get).toHaveBeenCalledWith(
187187
JOB_ENDPOINTS.GET_BY_KEY(JOB_TEST_CONSTANTS.JOB_KEY),
@@ -206,7 +206,7 @@ describe('JobService Unit Tests', () => {
206206
const mockRawJob = createMockRawJob();
207207
mockApiClient.get.mockResolvedValueOnce(mockRawJob);
208208

209-
const result = await jobService.getByKey(JOB_TEST_CONSTANTS.JOB_KEY, TEST_CONSTANTS.FOLDER_ID);
209+
const result = await jobService.getById(JOB_TEST_CONSTANTS.JOB_KEY, TEST_CONSTANTS.FOLDER_ID);
210210

211211
expect((result as any).CreationTime).toBeUndefined();
212212
expect((result as any).ReleaseName).toBeUndefined();
@@ -219,7 +219,7 @@ describe('JobService Unit Tests', () => {
219219
const mockRawJob = createMockRawJob();
220220
mockApiClient.get.mockResolvedValueOnce(mockRawJob);
221221

222-
const result = await jobService.getByKey(JOB_TEST_CONSTANTS.JOB_KEY, TEST_CONSTANTS.FOLDER_ID);
222+
const result = await jobService.getById(JOB_TEST_CONSTANTS.JOB_KEY, TEST_CONSTANTS.FOLDER_ID);
223223

224224
expect(result.getOutput).toBeDefined();
225225
expect(typeof result.getOutput).toBe('function');
@@ -229,12 +229,12 @@ describe('JobService Unit Tests', () => {
229229
const mockRawJob = createMockRawJob();
230230
mockApiClient.get.mockResolvedValueOnce(mockRawJob);
231231

232-
const options: JobGetByKeyOptions = {
232+
const options: JobGetByIdOptions = {
233233
expand: 'Robot,Machine,Release',
234234
select: 'Key,State,ReleaseName',
235235
};
236236

237-
await jobService.getByKey(JOB_TEST_CONSTANTS.JOB_KEY, TEST_CONSTANTS.FOLDER_ID, options);
237+
await jobService.getById(JOB_TEST_CONSTANTS.JOB_KEY, TEST_CONSTANTS.FOLDER_ID, options);
238238

239239
expect(mockApiClient.get).toHaveBeenCalledWith(
240240
JOB_ENDPOINTS.GET_BY_KEY(JOB_TEST_CONSTANTS.JOB_KEY),
@@ -249,16 +249,16 @@ describe('JobService Unit Tests', () => {
249249

250250
it('should throw validation error when jobKey is missing', async () => {
251251
await expect(
252-
jobService.getByKey('', TEST_CONSTANTS.FOLDER_ID)
253-
).rejects.toThrow('jobKey is required for getByKey');
252+
jobService.getById('', TEST_CONSTANTS.FOLDER_ID)
253+
).rejects.toThrow('jobKey is required for getById');
254254
});
255255

256256
it('should handle API errors', async () => {
257257
const error = createMockError(JOB_TEST_CONSTANTS.ERROR_JOB_NOT_FOUND);
258258
mockApiClient.get.mockRejectedValueOnce(error);
259259

260260
await expect(
261-
jobService.getByKey(JOB_TEST_CONSTANTS.JOB_KEY, TEST_CONSTANTS.FOLDER_ID)
261+
jobService.getById(JOB_TEST_CONSTANTS.JOB_KEY, TEST_CONSTANTS.FOLDER_ID)
262262
).rejects.toThrow(JOB_TEST_CONSTANTS.ERROR_JOB_NOT_FOUND);
263263
});
264264
});

0 commit comments

Comments
 (0)