Skip to content

Commit 977a6a4

Browse files
committed
Add getByFqn for more entities
1 parent a7160a5 commit 977a6a4

File tree

2 files changed

+165
-4
lines changed

2 files changed

+165
-4
lines changed

src/CustomClient.ts

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
import * as core from "./core";
21
import {
2+
WrappedAgents,
33
WrappedAgentVersions,
44
WrappedApplications,
5+
WrappedArtifacts,
56
WrappedArtifactVersions,
7+
WrappedDataDirectories,
8+
WrappedModels,
69
WrappedModelVersions,
10+
WrappedPrompts,
711
WrappedPromptVersions,
812
WrappedSecretGroups,
13+
WrappedTools,
914
WrappedToolVersions,
1015
WrappedTracingProjects,
1116
WrappedWorkspaces,
1217
} from "./api/resources/_WrappedClients";
1318
import { TrueFoundryClient as BaseTrueFoundryClient } from "./Client";
19+
import * as core from "./core";
1420

1521
export interface TrueFoundryClientOptions extends Omit<BaseTrueFoundryClient.Options, 'environment'> {
1622
baseUrl: core.Supplier<string>;
@@ -19,22 +25,32 @@ export interface TrueFoundryClientOptions extends Omit<BaseTrueFoundryClient.Opt
1925

2026
export class TrueFoundryClient extends BaseTrueFoundryClient {
2127
protected readonly _options: BaseTrueFoundryClient.Options;
28+
protected _agents: WrappedAgents | undefined;
2229
protected _agentVersions: WrappedAgentVersions | undefined;
2330
protected _applications: WrappedApplications | undefined;
31+
protected _artifacts: WrappedArtifacts | undefined;
2432
protected _artifactVersions: WrappedArtifactVersions | undefined;
33+
protected _dataDirectories: WrappedDataDirectories | undefined;
34+
protected _models: WrappedModels | undefined;
2535
protected _modelVersions: WrappedModelVersions | undefined;
36+
protected _prompts: WrappedPrompts | undefined;
2637
protected _promptVersions: WrappedPromptVersions | undefined;
2738
protected _secretGroups: WrappedSecretGroups | undefined;
39+
protected _tools: WrappedTools | undefined;
2840
protected _toolVersions: WrappedToolVersions | undefined;
2941
protected _tracingProjects: WrappedTracingProjects | undefined;
3042
protected _workspaces: WrappedWorkspaces | undefined;
3143

3244
constructor(_options: TrueFoundryClientOptions) {
33-
const options = {..._options, environment: _options.environment ?? ''}
45+
const options = { ..._options, environment: _options.environment ?? '' }
3446
super(options);
3547
this._options = options;
3648
}
3749

50+
public get agents(): WrappedAgents {
51+
return (this._agents ??= new WrappedAgents(this._options));
52+
}
53+
3854
public get agentVersions(): WrappedAgentVersions {
3955
return (this._agentVersions ??= new WrappedAgentVersions(this._options));
4056
}
@@ -43,14 +59,30 @@ export class TrueFoundryClient extends BaseTrueFoundryClient {
4359
return (this._applications ??= new WrappedApplications(this._options));
4460
}
4561

62+
public get artifacts(): WrappedArtifacts {
63+
return (this._artifacts ??= new WrappedArtifacts(this._options));
64+
}
65+
4666
public get artifactVersions(): WrappedArtifactVersions {
4767
return (this._artifactVersions ??= new WrappedArtifactVersions(this._options));
4868
}
4969

70+
public get dataDirectories(): WrappedDataDirectories {
71+
return (this._dataDirectories ??= new WrappedDataDirectories(this._options));
72+
}
73+
74+
public get models(): WrappedModels {
75+
return (this._models ??= new WrappedModels(this._options));
76+
}
77+
5078
public get modelVersions(): WrappedModelVersions {
5179
return (this._modelVersions ??= new WrappedModelVersions(this._options));
5280
}
5381

82+
public get prompts(): WrappedPrompts {
83+
return (this._prompts ??= new WrappedPrompts(this._options));
84+
}
85+
5486
public get promptVersions(): WrappedPromptVersions {
5587
return (this._promptVersions ??= new WrappedPromptVersions(this._options));
5688
}
@@ -59,6 +91,10 @@ export class TrueFoundryClient extends BaseTrueFoundryClient {
5991
return (this._secretGroups ??= new WrappedSecretGroups(this._options));
6092
}
6193

94+
public get tools(): WrappedTools {
95+
return (this._tools ??= new WrappedTools(this._options));
96+
}
97+
6298
public get toolVersions(): WrappedToolVersions {
6399
return (this._toolVersions ??= new WrappedToolVersions(this._options));
64100
}

src/api/resources/_WrappedClients.ts

Lines changed: 127 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1+
import * as core from "../../core";
2+
import * as TrueFoundry from "../index";
3+
import { Agents } from "./agents/client/Client";
14
import { AgentVersions } from "./agentVersions/client/Client";
25
import { Applications } from "./applications/client/Client";
6+
import { Artifacts } from "./artifacts/client/Client";
37
import { ArtifactVersions } from "./artifactVersions/client/Client";
8+
import { DataDirectories } from "./dataDirectories/client/Client";
9+
import { Models } from "./models/client/Client";
410
import { ModelVersions } from "./modelVersions/client/Client";
11+
import { Prompts } from "./prompts/client/Client";
512
import { PromptVersions } from "./promptVersions/client/Client";
613
import { SecretGroups } from "./secretGroups/client/Client";
14+
import { Tools } from "./tools/client/Client";
715
import { ToolVersions } from "./toolVersions/client/Client";
816
import { TracingProjects } from "./tracingProjects/client/Client";
917
import { Workspaces } from "./workspaces/client/Client";
10-
import * as core from "../../core"
11-
import * as TrueFoundry from "../index";
1218

1319
interface HasAsyncListMethod<T> {
1420
list(request: { fqn: string; limit?: number }, requestOptions?: object): Promise<core.Page<T>>;
@@ -30,6 +36,25 @@ async function getByFqn<T>(client: HasAsyncListMethod<T>, fqn: string, requestOp
3036
return result;
3137
}
3238

39+
export class WrappedAgents extends Agents {
40+
/**
41+
* Get agent API
42+
*
43+
* @param {string} fqn
44+
* @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
45+
*
46+
* @throws {@link TrueFoundry.UnprocessableEntityError}
47+
*
48+
* @example
49+
* await client.v1.agents.getByFqn("fqn")
50+
*/
51+
public async getByFqn(
52+
fqn: string,
53+
requestOptions?: Agents.RequestOptions,
54+
): Promise<TrueFoundry.GetAgentResponse> {
55+
return { data: await getByFqn(this, fqn, requestOptions) }
56+
}
57+
}
3358

3459
export class WrappedAgentVersions extends AgentVersions {
3560
/**
@@ -71,6 +96,26 @@ export class WrappedApplications extends Applications {
7196
}
7297
}
7398

99+
export class WrappedArtifacts extends Artifacts {
100+
/**
101+
* Get artifact API
102+
*
103+
* @param {string} fqn
104+
* @param {Artifacts.RequestOptions} requestOptions - Request-specific configuration.
105+
*
106+
* @throws {@link TrueFoundry.UnprocessableEntityError}
107+
*
108+
* @example
109+
* await client.v1.artifacts.getByFqn("fqn")
110+
*/
111+
public async getByFqn(
112+
fqn: string,
113+
requestOptions?: Artifacts.RequestOptions,
114+
): Promise<TrueFoundry.GetArtifactResponse> {
115+
return { data: await getByFqn(this, fqn, requestOptions) }
116+
}
117+
}
118+
74119
export class WrappedArtifactVersions extends ArtifactVersions {
75120
/**
76121
* Get artifact version API
@@ -91,6 +136,46 @@ export class WrappedArtifactVersions extends ArtifactVersions {
91136
}
92137
}
93138

139+
export class WrappedDataDirectories extends DataDirectories {
140+
/**
141+
* Get data directory API
142+
*
143+
* @param {string} fqn
144+
* @param {DataDirectories.RequestOptions} requestOptions - Request-specific configuration.
145+
*
146+
* @throws {@link TrueFoundry.UnprocessableEntityError}
147+
*
148+
* @example
149+
* await client.v1.dataDirectories.getByFqn("fqn")
150+
*/
151+
public async getByFqn(
152+
fqn: string,
153+
requestOptions?: DataDirectories.RequestOptions,
154+
): Promise<TrueFoundry.GetDataDirectoryResponse> {
155+
return { data: await getByFqn(this, fqn, requestOptions) }
156+
}
157+
}
158+
159+
export class WrappedModels extends Models {
160+
/**
161+
* Get model API
162+
*
163+
* @param {string} fqn
164+
* @param {Models.RequestOptions} requestOptions - Request-specific configuration.
165+
*
166+
* @throws {@link TrueFoundry.UnprocessableEntityError}
167+
*
168+
* @example
169+
* await client.v1.models.getByFqn("fqn")
170+
*/
171+
public async getByFqn(
172+
fqn: string,
173+
requestOptions?: Models.RequestOptions,
174+
): Promise<TrueFoundry.GetModelResponse> {
175+
return { data: await getByFqn(this, fqn, requestOptions) }
176+
}
177+
}
178+
94179
export class WrappedModelVersions extends ModelVersions {
95180
/**
96181
* Get model version API
@@ -111,6 +196,26 @@ export class WrappedModelVersions extends ModelVersions {
111196
}
112197
}
113198

199+
export class WrappedPrompts extends Prompts {
200+
/**
201+
* Get prompt API
202+
*
203+
* @param {string} fqn
204+
* @param {Prompts.RequestOptions} requestOptions - Request-specific configuration.
205+
*
206+
* @throws {@link TrueFoundry.UnprocessableEntityError}
207+
*
208+
* @example
209+
* await client.v1.prompts.getByFqn("fqn")
210+
*/
211+
public async getByFqn(
212+
fqn: string,
213+
requestOptions?: Prompts.RequestOptions,
214+
): Promise<TrueFoundry.GetPromptResponse> {
215+
return { data: await getByFqn(this, fqn, requestOptions) }
216+
}
217+
}
218+
114219
export class WrappedPromptVersions extends PromptVersions {
115220
/**
116221
* Get prompt version API
@@ -151,6 +256,26 @@ export class WrappedSecretGroups extends SecretGroups {
151256
}
152257
}
153258

259+
export class WrappedTools extends Tools {
260+
/**
261+
* Get tool API
262+
*
263+
* @param {string} fqn
264+
* @param {Tools.RequestOptions} requestOptions - Request-specific configuration.
265+
*
266+
* @throws {@link TrueFoundry.UnprocessableEntityError}
267+
*
268+
* @example
269+
* await client.v1.tools.getByFqn("fqn")
270+
*/
271+
public async getByFqn(
272+
fqn: string,
273+
requestOptions?: Tools.RequestOptions,
274+
): Promise<TrueFoundry.GetToolResponse> {
275+
return { data: await getByFqn(this, fqn, requestOptions) }
276+
}
277+
}
278+
154279
export class WrappedToolVersions extends ToolVersions {
155280
/**
156281
* Get tool version API

0 commit comments

Comments
 (0)