Skip to content

Commit

Permalink
chore: added configs api after testing
Browse files Browse the repository at this point in the history
  • Loading branch information
shivam-pareek committed Sep 26, 2024
1 parent aceface commit 48b57db
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 147 deletions.
113 changes: 0 additions & 113 deletions src/apis/apiKeys.ts

This file was deleted.

88 changes: 56 additions & 32 deletions src/apis/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,86 +3,110 @@ import { APIResponseType, ApiClientInterface } from "../_types/generalTypes";
import { APIPromise, RequestOptions } from "../baseClient";
import { createHeaders } from "./createHeaders";

export interface ConfigCreateParams {
export interface ConfigsCreateParams {
name?: string;
config?: Record<string, unknown>;
isDefault?: number;
workspace_id?:string;
}

export interface ConfigRetrieveParams {
slug: string?;
export interface ConfigsRetrieveParams {
slug?: string;
}

export interface ConfigUpdateParams {
slug: string;
name: string;
config: Record<string, unknown>;
status: string;
export interface ConfigsUpdateParams {
slug?: string;
name?: string;
config?: Record<string, unknown>;
status?: string;
}

export interface ConfigCreateResponse extends APIResponseType {
success: boolean;
data: Record<string, unknown>;
export interface ConfigsCreateResponse extends APIResponseType {
id?: string;
version_id?: string;
slug?: string;
object?: string;
}
export interface ConfigRetrieveResponse extends APIResponseType {
success: boolean;
data: Record<string, unknown>;
export interface ConfigsRetrieveResponse extends APIResponseType {
ide?: string;
name?: string;
workspace_id?: string;
slug?: string;
organization_id?: string;
is_default?: number;
status?: string;
owner_id?: string;
created_at?: string;
updated_by?: string;
last_updated_at?: string;
config?: Record<string, unknown>;
format?: string;
type?: string;
version_id?: string;
object?: string;
}
export interface ConfigListResponse extends APIResponseType {
sucess: boolean;
data: Record<string, unknown>[];
export interface ConfigsListResponse extends APIResponseType {
object?: boolean;
total?: number;
data?: Record<string, unknown>[];
}
export interface ConfigUpdateResponse extends APIResponseType {
success: boolean;
data: Record<string, unknown>;
export interface ConfigsUpdateResponse extends APIResponseType {
version_id?: string;
object?: string;
}
export class Configs extends ApiResource {
constructor(client: any) {
super(client);
}
create(
_body: ConfigCreateParams,
_body: ConfigsCreateParams,
params?: ApiClientInterface,
opts?: RequestOptions
): APIPromise<ConfigCreateResponse> {
): APIPromise<ConfigsCreateResponse> {
const body = _body;
if (params) {
this.client.customHeaders = { ...this.client.customHeaders, ...createHeaders({ ...params }) }
}
const response = this.post<ConfigCreateResponse>('/configs', { body, ...opts });
const response = this.post<ConfigsCreateResponse>('/configs', { body, ...opts });
return response;
}

retrieve(
_body: ConfigRetrieveParams,
_body: ConfigsRetrieveParams,
params?: ApiClientInterface,
opts?: RequestOptions
): APIPromise<ConfigRetrieveResponse> {
): APIPromise<ConfigsRetrieveResponse> {
const body = _body;
const slug = body.slug;
if (params) {
this.client.customHeaders = { ...this.client.customHeaders, ...createHeaders({ ...params }) }
}
const response = this.get<ConfigRetrieveResponse>(`/configs/${slug}`, { body, ...opts });
const response = this.get<ConfigsRetrieveResponse>(`/configs/${slug}`, { body, ...opts });
return response;
}

update(
_body: ConfigUpdateParams,
_body: ConfigsUpdateParams,
params?: ApiClientInterface,
opts?: RequestOptions
): APIPromise<ConfigUpdateResponse> {
): APIPromise<ConfigsUpdateResponse> {
const body = _body;
const slug = body.slug;
if (params) {
this.client.customHeaders = { ...this.client.customHeaders, ...createHeaders({ ...params }) }
}
const response = this.put<ConfigUpdateResponse>(`/configs/${slug}`, { body, ...opts });
const response = this.put<ConfigsUpdateResponse>(`/configs/${slug}`, { body, ...opts });
return response;
}
list():APIPromise<ConfigListResponse>{
const response = this.get<ConfigListResponse>('/configs', {});
list(
_body?:any, //? will be removed when query params will be introduced
params?: ApiClientInterface,
opts?: RequestOptions
):APIPromise<ConfigsListResponse>{
const body = _body;
if (params) {
this.client.customHeaders = { ...this.client.customHeaders, ...createHeaders({ ...params }) }
}
const response = this.get<ConfigsListResponse>(`/configs`, { body, ...opts});
return response;
}
}
Expand Down
1 change: 0 additions & 1 deletion src/apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export { MainFiles } from "./files";
export { Models } from "./models";
export { Admin } from "./admin";
export { Configs } from "./configs";
export { ApiKeys } from "./apiKeys"
export { Batches } from "./batches";
export { FineTuning } from "./fineTuning"
export { Moderations } from "./moderations"
Expand Down
1 change: 0 additions & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ export class Portkey extends ApiClient {
uploads = new API.Uploads(this);
admin = new API.Admin(this);
configs = new API.Configs(this);
apiKeys = new API.ApiKeys(this);
beta = {
assistants: new API.Assistants(this),
threads: new API.Threads(this),
Expand Down

0 comments on commit 48b57db

Please sign in to comment.