Skip to content

Add getByFqn for more entities #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions src/CustomClient.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import * as core from "./core";
import {
WrappedAgents,
WrappedAgentVersions,
WrappedApplications,
WrappedArtifacts,
WrappedArtifactVersions,
WrappedDataDirectories,
WrappedModels,
WrappedModelVersions,
WrappedPrompts,
WrappedPromptVersions,
WrappedSecretGroups,
WrappedTools,
WrappedToolVersions,
WrappedTracingProjects,
WrappedWorkspaces,
} from "./api/resources/_WrappedClients";
import { TrueFoundryClient as BaseTrueFoundryClient } from "./Client";
import * as core from "./core";

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

export class TrueFoundryClient extends BaseTrueFoundryClient {
protected readonly _options: BaseTrueFoundryClient.Options;
protected _agents: WrappedAgents | undefined;
protected _agentVersions: WrappedAgentVersions | undefined;
protected _applications: WrappedApplications | undefined;
protected _artifacts: WrappedArtifacts | undefined;
protected _artifactVersions: WrappedArtifactVersions | undefined;
protected _dataDirectories: WrappedDataDirectories | undefined;
protected _models: WrappedModels | undefined;
protected _modelVersions: WrappedModelVersions | undefined;
protected _prompts: WrappedPrompts | undefined;
protected _promptVersions: WrappedPromptVersions | undefined;
protected _secretGroups: WrappedSecretGroups | undefined;
protected _tools: WrappedTools | undefined;
protected _toolVersions: WrappedToolVersions | undefined;
protected _tracingProjects: WrappedTracingProjects | undefined;
protected _workspaces: WrappedWorkspaces | undefined;

constructor(_options: TrueFoundryClientOptions) {
const options = {..._options, environment: _options.environment ?? ''}
const options = { ..._options, environment: _options.environment ?? '' }
super(options);
this._options = options;
}

public get agents(): WrappedAgents {
return (this._agents ??= new WrappedAgents(this._options));
}

public get agentVersions(): WrappedAgentVersions {
return (this._agentVersions ??= new WrappedAgentVersions(this._options));
}
Expand All @@ -43,14 +59,30 @@ export class TrueFoundryClient extends BaseTrueFoundryClient {
return (this._applications ??= new WrappedApplications(this._options));
}

public get artifacts(): WrappedArtifacts {
return (this._artifacts ??= new WrappedArtifacts(this._options));
}

public get artifactVersions(): WrappedArtifactVersions {
return (this._artifactVersions ??= new WrappedArtifactVersions(this._options));
}

public get dataDirectories(): WrappedDataDirectories {
return (this._dataDirectories ??= new WrappedDataDirectories(this._options));
}

public get models(): WrappedModels {
return (this._models ??= new WrappedModels(this._options));
}

public get modelVersions(): WrappedModelVersions {
return (this._modelVersions ??= new WrappedModelVersions(this._options));
}

public get prompts(): WrappedPrompts {
return (this._prompts ??= new WrappedPrompts(this._options));
}

public get promptVersions(): WrappedPromptVersions {
return (this._promptVersions ??= new WrappedPromptVersions(this._options));
}
Expand All @@ -59,6 +91,10 @@ export class TrueFoundryClient extends BaseTrueFoundryClient {
return (this._secretGroups ??= new WrappedSecretGroups(this._options));
}

public get tools(): WrappedTools {
return (this._tools ??= new WrappedTools(this._options));
}

public get toolVersions(): WrappedToolVersions {
return (this._toolVersions ??= new WrappedToolVersions(this._options));
}
Expand Down
129 changes: 127 additions & 2 deletions src/api/resources/_WrappedClients.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import * as core from "../../core";
import * as TrueFoundry from "../index";
import { Agents } from "./agents/client/Client";
import { AgentVersions } from "./agentVersions/client/Client";
import { Applications } from "./applications/client/Client";
import { Artifacts } from "./artifacts/client/Client";
import { ArtifactVersions } from "./artifactVersions/client/Client";
import { DataDirectories } from "./dataDirectories/client/Client";
import { Models } from "./models/client/Client";
import { ModelVersions } from "./modelVersions/client/Client";
import { Prompts } from "./prompts/client/Client";
import { PromptVersions } from "./promptVersions/client/Client";
import { SecretGroups } from "./secretGroups/client/Client";
import { Tools } from "./tools/client/Client";
import { ToolVersions } from "./toolVersions/client/Client";
import { TracingProjects } from "./tracingProjects/client/Client";
import { Workspaces } from "./workspaces/client/Client";
import * as core from "../../core"
import * as TrueFoundry from "../index";

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

export class WrappedAgents extends Agents {
/**
* Get agent API
*
* @param {string} fqn
* @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link TrueFoundry.UnprocessableEntityError}
*
* @example
* await client.v1.agents.getByFqn("fqn")
*/
public async getByFqn(
fqn: string,
requestOptions?: Agents.RequestOptions,
): Promise<TrueFoundry.GetAgentResponse> {
return { data: await getByFqn(this, fqn, requestOptions) }
}
}

export class WrappedAgentVersions extends AgentVersions {
/**
Expand Down Expand Up @@ -71,6 +96,26 @@ export class WrappedApplications extends Applications {
}
}

export class WrappedArtifacts extends Artifacts {
/**
* Get artifact API
*
* @param {string} fqn
* @param {Artifacts.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link TrueFoundry.UnprocessableEntityError}
*
* @example
* await client.v1.artifacts.getByFqn("fqn")
*/
public async getByFqn(
fqn: string,
requestOptions?: Artifacts.RequestOptions,
): Promise<TrueFoundry.GetArtifactResponse> {
return { data: await getByFqn(this, fqn, requestOptions) }
}
}

export class WrappedArtifactVersions extends ArtifactVersions {
/**
* Get artifact version API
Expand All @@ -91,6 +136,46 @@ export class WrappedArtifactVersions extends ArtifactVersions {
}
}

export class WrappedDataDirectories extends DataDirectories {
/**
* Get data directory API
*
* @param {string} fqn
* @param {DataDirectories.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link TrueFoundry.UnprocessableEntityError}
*
* @example
* await client.v1.dataDirectories.getByFqn("fqn")
*/
public async getByFqn(
fqn: string,
requestOptions?: DataDirectories.RequestOptions,
): Promise<TrueFoundry.GetDataDirectoryResponse> {
return { data: await getByFqn(this, fqn, requestOptions) }
}
}

export class WrappedModels extends Models {
/**
* Get model API
*
* @param {string} fqn
* @param {Models.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link TrueFoundry.UnprocessableEntityError}
*
* @example
* await client.v1.models.getByFqn("fqn")
*/
public async getByFqn(
fqn: string,
requestOptions?: Models.RequestOptions,
): Promise<TrueFoundry.GetModelResponse> {
return { data: await getByFqn(this, fqn, requestOptions) }
}
}

export class WrappedModelVersions extends ModelVersions {
/**
* Get model version API
Expand All @@ -111,6 +196,26 @@ export class WrappedModelVersions extends ModelVersions {
}
}

export class WrappedPrompts extends Prompts {
/**
* Get prompt API
*
* @param {string} fqn
* @param {Prompts.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link TrueFoundry.UnprocessableEntityError}
*
* @example
* await client.v1.prompts.getByFqn("fqn")
*/
public async getByFqn(
fqn: string,
requestOptions?: Prompts.RequestOptions,
): Promise<TrueFoundry.GetPromptResponse> {
return { data: await getByFqn(this, fqn, requestOptions) }
}
}

export class WrappedPromptVersions extends PromptVersions {
/**
* Get prompt version API
Expand Down Expand Up @@ -151,6 +256,26 @@ export class WrappedSecretGroups extends SecretGroups {
}
}

export class WrappedTools extends Tools {
/**
* Get tool API
*
* @param {string} fqn
* @param {Tools.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link TrueFoundry.UnprocessableEntityError}
*
* @example
* await client.v1.tools.getByFqn("fqn")
*/
public async getByFqn(
fqn: string,
requestOptions?: Tools.RequestOptions,
): Promise<TrueFoundry.GetToolResponse> {
return { data: await getByFqn(this, fqn, requestOptions) }
}
}

export class WrappedToolVersions extends ToolVersions {
/**
* Get tool version API
Expand Down